- To write program for blinking 8 LEDs for above given circuit, you have to define 8 variables first.
- Then you have to write 8 pinMode statements.
- Then you have to write 8+8=16 digitalWrite commands to make the LEDs on/off.
- This is sooooooo boring…!
Connection Details
The Code
int LED0=0;
int LED1=1;
int LED2=2;
int LED3=3;
int LED4=4;
int LED5=5;
int LED6=6;
int LED7=7;
void setup()
{
pinMode(LED0, OUTPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
pinMode(LED7, OUTPUT);
}
void loop()
{
digitalWrite(LED0, HIGH);
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, HIGH);
digitalWrite(LED5, HIGH);
digitalWrite(LED6, HIGH);
digitalWrite(LED7, HIGH);
delay(1000);
digitalWrite(LED0, LOW);
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
digitalWrite(LED5, LOW);
digitalWrite(LED6, LOW);
digitalWrite(LED7, LOW);
delay(1000);
}
Related Posts