How to blink an LED with Arduino

Post Reply
User avatar
Shehani
Lieutenant
Lieutenant
Posts: 61
Joined: Mon Aug 19, 2013 2:11 pm

How to blink an LED with Arduino

Post by Shehani » Thu Sep 26, 2013 12:31 pm

Blinking LED will be the maiden step you guys might have taken while stepping into microcontroller programmings. We have already discussed led blinking in PIC section. Now lets have a look at ARDUINO development board, which is an open-source electronics prototyping platform. I am using Ardiuno uno R3, which is latest uno model of arduino family. But, you guys need not be worried about the model, since all the models are programmed in almost similar way.
1.jpg
1.jpg (7.12 KiB) Viewed 1191 times
For this, first you need is an ARDUINO software. Since arduino is open source, you need not pay for this.

Download it from here:-

Windows
Mac OS

You will get a ‘.zip’ file and extract it somewhere in your pc. No installation is required.

1. Open the application file named Arduino (with blue icon)

2. File >> New ( ctrl + N )
2.jpg
2.jpg (21.51 KiB) Viewed 1191 times
3. Led blinking code

Code: Select all

int led = 13;
void setup() {
 pinMode(led, OUTPUT); // initialize the digital pin as an output.
 }
void loop() {
 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
 delay(1000); // wait for a second
 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
 delay(1000); // wait for a second
 }
This programme turns on an LED on for one second, then off for one second, repeatedly.

Pin 13 has an LED connected on most Arduino boards, that is why I have choosen pin13 as out pin.

4. Save it as LED_BLINK (as you like)

5. Connect your Arduino board

6. Select the model form Tools >> Board
3.jpg
3.jpg (56.54 KiB) Viewed 1191 times
7. Select the port to which your board is connected from Tools >> Serial Port
4.jpg
4.jpg (35.89 KiB) Viewed 1191 times
8. Upload the code to your Arduino
5.jpg
5.jpg (35.5 KiB) Viewed 1191 times
Now the built-in LED will blink as per the given programme. Or you can connect an LED in pin13 – Gnd.
Arduino can be programmed directly through usb.




Article courtesy of electrosome.com
Post Reply

Return to “Arduino”