ARDUINO : Blinking LED experiment

If you are new to Arduino, it is a small Atmel microcontroller powered board which we can connect to a computer and program easily.
There are a lot of Arduino boards available in the market like Uno, nano, mega, etc.
Arduino Uno

The first thing you have do is to get an Arduino board, then download Arduino IDE. The best thing about Arduino is that it can be programmed using C++ and there are a lot of libraries and many example programs.
You can find Arduino IDE in Arduino's official website.
Once you have downloaded and installed the Arduino IDE, open the IDE.

  

                               Arduino IDE



It is in this IDE, we write our C++ program and upload and run it on the Arduino board.

BLINKING LED

It is the simplest program in Arduino like the "hello world" program. This program controls an LED connected to the Arduino and the led blinks with a time period of 2 sec.

SETTING UP OF ARDUINO BOARD

Connect the led's -ve terminal to the ground pin in Arduino board and +ve pin to digital pin 13(you can use any other digital pins, but in the program, you have to use that pin number instead of 13) with a 220-ohm resistance in series.


                         Connection diagram



Now connect the Arduino board to the computer and open the Arduino IDE. In the IDE type the following code.

 // LED_blink program  
 // LED blinks with a time period of 2 sec.  
 void setup() {  
  // initialize digital pin 13 as an output.  
  pinMode(13, OUTPUT);  
 }  
 // the loop function runs over and over again forever  
 void loop() {  
    // turn the LED on (HIGH is the voltage level)  
  digitalWrite(13, HIGH);  
  delay(1000);            // wait for a second  
  digitalWrite(13, LOW);  
  // turn the LED off by making the voltage LOW  
  delay(1000);            // wait for a second  
 }  

Now select upload from the Sketch menu. When the upload completes you can see that the LED starts to blink.








tony

No comments:

Post a Comment