// C++ code
void setup()
{
pinMode(8, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(8, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
Explain : The void setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. It runs only one time. The void loop() function is used to run loop. Step 1: void setup() use initialize the pins. Step 2: Set the pinMode (8,OUTPUT) - means use for 8 no. pin on arduino for Output. Step 3: Use void loop()- it is use to run loop Step 4: Set digitalWrite(8, HIGH) - means digitalWrite use for output 8 pin is on. (We can use HIGH or 1 for On.) Step 5: Set delay(1000) which makes 1 sec. on the light. Step 6: digitalWrite(8, LOW) it off the light (Use LOW or 0 for off.) Step 7: Set delay. In Diagram : Use Arduino Board and connect bulb with it. 8 pin is connected to Anode and Ground is conneted to Cathode.