GR-ADZUKIでLチカからダイナミック点灯

まずは、いつも通り、LEDをチカチカさせます。

http://gadget.renesas.com/ja/product/adzuki_sp2.html
今回は、IDE For ＧＲを使用します。
LEDはPin6, 9, 10, 11, 12, 13につながっています。
さらに、
赤は22へ、緑は23、青は24へつながっており、黄色にしたい場合は、22，23ピンをHighにすることで点灯可能です。

http://gadget.renesas.com/ja/reference/adzuki/library_digitalio.html

以下は、全色点灯なので、白色になります。
１２，１３のLEDを白色で点灯点滅を繰り返します。

```
#include <RLduino78.h>
#define LED_R_COM 22
#define LED_G_COM 23
#define LED_B_COM 24
void setup()
{
void setup(){
	pinMode(LED_R_COM, OUTPUT);
	pinMode(LED_G_COM, OUTPUT);
	pinMode(LED_B_COM, OUTPUT);
	pinMode(12, OUTPUT);
	pinMode(13, OUTPUT);
	digitalWrite(LED_R_COM, HIGH); // red LED on
	digitalWrite(LED_G_COM, HIGH); // green LED on
	digitalWrite(LED_B_COM, HIGH); // blue LED on
}
 
void loop()
{
	digitalWrite(12, HIGH);
	digitalWrite(13, LOW);
	delay(100);
	digitalWrite(12, LOW);
	digitalWrite(13, HIGH);
	delay(100);
}
```
次は、５個のLEDを順々に点滅をさせます。

```
/*GR-ADZUKI Sketch Template Version: V2.02*/
#include <Arduino.h>
#define LED_R_COM 22
#define LED_G_COM 23
#define LED_B_COM 24

void setup(){
	pinMode(LED_R_COM, OUTPUT);
	pinMode(LED_G_COM, OUTPUT);
	pinMode(LED_B_COM, OUTPUT);
	pinMode(6, OUTPUT);
	pinMode(9, OUTPUT);
	pinMode(10, OUTPUT);
	pinMode(11, OUTPUT);
	pinMode(12, OUTPUT);
	pinMode(13, OUTPUT);
	digitalWrite(LED_R_COM, HIGH); // red LED on
	digitalWrite(LED_G_COM, HIGH); // green LED on
	digitalWrite(LED_B_COM, HIGH); // blue LED on
}

void loop(){
	digitalWrite(6, HIGH);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	delay(50);
	digitalWrite(6, LOW);
	digitalWrite(9, HIGH);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	delay(50);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, HIGH);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	delay(50);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, HIGH);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	delay(50);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, HIGH);
	digitalWrite(13, LOW);
	delay(50);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, HIGH);
	delay(100);
}
```

次は、Delayの数字を小さくしてみましょう。
Delayは、間隔です。
一定以下の間隔にすると、LEDが消えているのがわからなくなると思います。

これがダイナミック点灯です。
ダイナミック点灯は、個別のピンを常時操作するのではなく人が視認できない範囲でON-OFFを繰り返して
点灯しているように見せる手法です。
逆に、個別に常時操作することをスタティック点灯といいます。

```
/*GR-ADZUKI Sketch Template Version: V2.02*/
#include <Arduino.h>
#define LED_R_COM 22
#define LED_G_COM 23
#define LED_B_COM 24

void setup(){
	pinMode(LED_R_COM, OUTPUT);
	pinMode(LED_G_COM, OUTPUT);
	pinMode(LED_B_COM, OUTPUT);
	pinMode(6, OUTPUT);
	pinMode(9, OUTPUT);
	pinMode(10, OUTPUT);
	pinMode(11, OUTPUT);
	pinMode(12, OUTPUT);
	pinMode(13, OUTPUT);
	digitalWrite(LED_R_COM, HIGH); // red LED on
	digitalWrite(LED_G_COM, HIGH); // green LED on
	digitalWrite(LED_B_COM, HIGH); // blue LED on
}
void loop(){
	digitalWrite(6, HIGH);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, HIGH);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, HIGH);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, HIGH);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, HIGH);
	digitalWrite(13, LOW);
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, HIGH);
	delay(3);
}
```

ちょっと弄ってみましょう

```
/*GR-ADZUKI Sketch Template Version: V2.02*/
#include <Arduino.h>
#define LED_R_COM 22
#define LED_G_COM 23
#define LED_B_COM 24

void setup(){
	pinMode(LED_R_COM, OUTPUT);
	pinMode(LED_G_COM, OUTPUT);
	pinMode(LED_B_COM, OUTPUT);
	pinMode(6, OUTPUT);
	pinMode(9, OUTPUT);
	pinMode(10, OUTPUT);
	pinMode(11, OUTPUT);
	pinMode(12, OUTPUT);
	pinMode(13, OUTPUT);
}

void loop(){
	digitalWrite(6, HIGH);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	digitalWrite(LED_R_COM, HIGH); // red LED on
	digitalWrite(LED_G_COM, LOW);// green LED on
	digitalWrite(LED_B_COM, LOW);// blue LED on
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, HIGH);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	digitalWrite(LED_R_COM, LOW);// red LED on
	digitalWrite(LED_G_COM, LOW);// green LED on
	digitalWrite(LED_B_COM, HIGH); // blue LED on
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, HIGH);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	digitalWrite(LED_R_COM, LOW);// red LED on
	digitalWrite(LED_G_COM, HIGH); // green LED on
	digitalWrite(LED_B_COM, LOW);// blue LED on
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, HIGH);
	digitalWrite(12, LOW);
	digitalWrite(13, LOW);
	digitalWrite(LED_R_COM, HIGH); // red LED on
	digitalWrite(LED_G_COM, HIGH); // green LED on
	digitalWrite(LED_B_COM, LOW);// blue LED on
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, HIGH);
	digitalWrite(13, LOW);
	digitalWrite(LED_R_COM, LOW);// red LED on
	digitalWrite(LED_G_COM, HIGH); // green LED on
	digitalWrite(LED_B_COM, HIGH); // blue LED on
	delay(3);
	digitalWrite(6, LOW);
	digitalWrite(9, LOW);
	digitalWrite(10, LOW);
	digitalWrite(11, LOW);
	digitalWrite(12, LOW);
	digitalWrite(13, HIGH);
	digitalWrite(LED_R_COM, HIGH); // red LED on
	digitalWrite(LED_G_COM, LOW);// green LED on
	digitalWrite(LED_B_COM, HIGH); // blue LED on
	delay(3);
}
```

これ実は、一定間隔で点滅を繰り返しているんです。
![GR-ADZUKI-dynamic.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/285344/41e2a920-c590-c374-b32f-1713a3667431.jpeg)