LED blinking With Arduino UNO
Advertisement
In this blog, we are going to make LED Blinking Program for Arduino UNO, which is the basic project of the embedded system.
Let’s puts some LEDs and resistors to work. In this project, we will use one led and some resistor to make our project perfect (LED Blinking Arduino UNO).
LED Blinking Arduino UNO Algorithm
Before starting to write the algorithm of the project first know what is an algorithm. Basically, the Algorithm is a step-by-step method, which specifies a series of instructions to be executed to get the desired output in a certain order.
Algorithms are usually generated independently of the underlying languages, i.e. in more than one programming language, an algorithm may be implemented.
So, start writing the algorithm of our first project #1. Before going onto the algorithm part you should have a clear understanding of what is an Arduino UNO and the basics parts.
- Turn on the LED 1
- Wait for a second
- Turn off the LED 1
- Repeat this process indefinitely
Required Components for LED Blinking Project in Arduino UNO
- One led
- A Resistor
- One Bread Board
- Wires
- Arduino
- USB Cables
Arduino Code for LED Blinking
Here is the code for the LED Blinking Program.
//initialize variables (for pin)
int ledPin = 11;
void setup()
{
//set the pin mode to output
pinMode(ledPin, OUTPUT);
}
void loop()
{
// send a HIGH(ON) signal to ledPin which is pin 11
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
In void setup() at the digital, I/O pins are set to outputs because we want them to send current to the LED on demand. We specify when to turn led using the digitalWrite()
function in the void loop()
section of the sketch.
Use Variables
In a computer program, data is stored using variables. For instance, in Project (LED BLINKING ARDUINO UNO) we used the delay(1000) feature to hold the LED Turns on.
LED Blinking Circuit Diagram
Now let’s build the circuit. A circuit layout can be described in several ways. For this project (LED BLINKING ARDUINO UNO), we are using a physical layout diagram similar to the one shown in the above figure.
By comparing the wiring diagram with the sketched functions, You should start making sense of the circuit. When we use for example DigitalWrite(11, HIGH), a 5 V high-voltage digital pin, 11 flows through, The current-limiting resistor, the anode through the LED, and then the anode Cathode, and finally back to the GND socket in Arduino to complete the circuit. Then by using DigitalWrite(11, LOW) the current stops and the LED turns off.
Working Explanation of LED Blinking
Attach your Arduino now, and upload your sketch from the Arduino IDE. After a second the LEDs should start blinking.
However, if nothing happens then remove the USB cable immediately From Arduino and verify that the sketch has been typed correctly.
Fix a mistake, and upload the sketch again If your sketch matches exactly and the LEDs still don’t blink, check your wiring on the breadboard. if you wanted to modify this sketch to make the LEDs cycle more quickly, you would need to blink after each delay(500)
.
There is a better way. if you want to see the stimulation of the project. Click here https://www.tinkercad.com/things/jcjIKbEOLLn.