1. Blinking LED
Aim of the project:
Turn on LED for one second, off for one second, and repeat forever.
Hardware: Arduino UNO board, jumpers, 220Ω resistor, LED, breadboard.
Software: Arduino IDE
Here let’s write a program to blink an LED for every 1000ms that means for 1 second. In Arduino UNO, a LED will be already designed at the pin13 which is in-built in the arduin0 UNO board, but we are not going to use it. Here we are going to connect an indicating LED to PIN 9 through a current limiting resistor. After you build the circuit plug your Arduino board into your computer, start the IDE and enter the code. You may also load it from the menu File/Examples/01.Basics/Blink.
This picture shows you the code obtained in the above mentioned path in the Arduino IDE and the code we used in our experiment is explained as below.
Initialize pin 9 as an output pin.
pinMode (9, OUTPUT);
In the main loop, you turn the LED on with the line:
digitalWrite (9, HIGH);
This supplies 5 volts to the LED anode. That creates a voltage difference across the pins of the LED, and lights it up. Then you turn it off with the line:
digitalWrite (9, LOW);
That takes the pin 9 back to zero volts, and turns the LED off. In between the on and the off, you want enough time for a person to see the change, so the delay() commands tell the board to do nothing for 1000 milliseconds, or one second. When you use the delay() command, nothing else happens for that amount of time.
LED will get turn on and stay in that condition for 1 second then it gets turned off. This repeats until you disconnect the supply.