0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

arduinoでRGB LED その3

Last updated at Posted at 2021-09-23

概要

arduinoでRGB LEDやってみた。
wemos d1で、やってみた。

配線

vcc - 5.0v
gnd - gnd
out - D9

サンプルコード

7個が、ランダムに光る。

int l[30]; 
int b8[8] = {
	0b10000000,
	0b01000000,
	0b00100000,
	0b00010000,
	0b00001000,
	0b00000100,
	0b00000010,
	0b00000001,
};

void bit_off() {
	GPOS = 1 << 2;
	GPOS = 1 << 2;
	GPOS = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
}
void bit_on() {
	GPOS = 1 << 2;
	GPOS = 1 << 2;
	GPOS = 1 << 2;
	GPOS = 1 << 2;
	GPOS = 1 << 2;
	GPOS = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
	GPOC = 1 << 2;
}

void setup() {
	pinMode(2, OUTPUT);
}
void loop() {
	int on_off;
	int i;
	int  j;
	for (i = 0; i < 27; i++)
	{
		l[i] = random(32);
	}
	for (i = 0; i < 27; i++)
	{
		for (j = 0; j < 8; j++)
		{
			on_off = l[i] & b8[j];
			if (on_off == 0)
			{
				bit_off();
			}
			else
			{
				bit_on();
			}
		}
	}
	delay(100);
}





以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?