Introduction
In this tutorial, you are going to learn how to Control led using Arduino UNO.
The led Turned on for one second and off for one second.
Parts Required
PARTS | QUANTITY | PURCHASE LINK | |
Arduino UNO | 1 | https://amzn.to/2TvSOxY | |
A-B Cable | 1 | ||
LED | 1 |
|
|
220ohm Resistor | 1 | ||
Connecting Wires | As Per Required |
|
|
BreadBoard | 1 |
Circuit Diagram
Programming
For programming this concept we need to understand some basic syntax of Arduino IDE. Before that, the first thing is we need to install Arduino IDE. After that, we need to understand how the Arduino program works.
For control led we need to declare led as output
pinMode(PIN Number, Device TYPE);
PIN Number– The pin, to which we have connected the device. In this case, I have attached to 13 no pin of Arduino UNO.
Device Type– What is the device type. For output devices, we need to declare the type as OUTPUT and for input devices, we need to declare as INPUT. In this case, we have connected Led. As we know, LED is an output device. so we have to program
pinMode(13, OUTPUT);
After declare we need to turn on/ off led. so, to do that we need to understand about digitalWrite()
digitalWrite(PIN Number, Status);
PIN Number– in which pin we have connected the device. In this case, I have attached to 13 no pin of Arduino UNO
Status– status means we need to turn the led on/off. For turning led on we can write HIGH or 1 and for turning off led we can write LOW or 0.
Final Code
/*
Tested by robogenesis.in
This program blinks pin 13 of the Arduino (the built-in LED)
*/
void setup(){
pinMode(13,OUTPUT); //declare led as output
}
void loop(){
digitalWrite(13, HIGH); //Turn on led
delay(1000); // delay for 1 sec
digitalWrite(13, HIGH);//turn off led
delay(1000); //delay for one second
}
Comments