LEDs are available in a range of colors,
but the LED connected to pin 13 on the Arduino is normally green. The
LED lights up when a current is applied to it, so you can use pin 13
like a switch. When you switch it on, it will light up the LED, and when
you switch it off, it will turn off the LED.
Let’s start by writing the sketch.
void setup(){
pinMode(13, OUTPUT);}
void loop(){
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
The code is straightforward. You’re assigning digital pin 13 as an output, and then you’re looping through some code that switches pin 13 on to HIGH or LOW for 1 second. The delay value is given in milliseconds, so 1000 milliseconds give you a delay time of 1 second.
Now connect LED with Arduino board as shown in fig :
+LED -> Arduino Pin -13
-LED -> Ground
Uploading:
Go to Tools>Board> Select Board which you have
Now,
Go to Tools>Serial Port>Select Port on which Arduino is connected with your Computer.
Now click on upload button as shown in fig:
or
Press ctrl+U
LED will start blinking at 1 sec interval if you follow all the instruction in right order.
No comments:
Post a Comment