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 5 years have passed since last update.

GR-ADZUKIでダイナミック点灯(2)

Posted at

GR-ADZUKIでダイナミック点灯の第2弾です。

今回は、コードを変更しています。
というのは、Arrayのコードで良いサイトがあったからです。
https://www.hiramine.com/physicalcomputing/arduino/rgbbarled.html
こちらを使わせていただきました。

GR-ADZUKI-dynamic-2.jpg

ANODEPINとCATHODEPINを変更します。
int ANODEPIN[6] = { 6,9,10,11,12,13};
int CATHODEPIN[3] = { 22,23,24 }; // R, G, B

// (C)https://www.hiramine.com/physicalcomputing/arduino/rgbbarled.html
// 仕様:カソードコモン
int ANODEPIN[6] = { 6,9,10,11,12,13};
int CATHODEPIN[3] = { 22,23,24 };	// R, G, B

void setup()
{
	// アノードを、LOWで初期化
	for( int ano = 0; ano < 6; ano++ )
	{
		pinMode( ANODEPIN[ano], OUTPUT );
		digitalWrite( ANODEPIN[ano], LOW );
	}

	// カソードを、HIGHで初期化
	for( int cat = 0; cat < 3; cat++ )
	{
		pinMode( CATHODEPIN[cat], OUTPUT );
		digitalWrite( CATHODEPIN[cat], HIGH );
	}
}

void loop()
{
	// カソードのループ
	for( int cat = 0; cat < 3; cat++ )
	{
		digitalWrite( CATHODEPIN[cat], LOW );	// LOWに変更
		// アノードのループ
		for( int ano = 0; ano < 6; ano++ )
		{
			digitalWrite( ANODEPIN[ano], HIGH );	// HIGHに変更
			delay(5);	//点灯時間
			digitalWrite( ANODEPIN[ano], LOW );	// LOWに戻す
		}
		digitalWrite( CATHODEPIN[cat], HIGH );	// HIGHに戻す
	}
}
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?