Space In HIndi

 


Pages

Popular

Interfacing with Arduino

The exciting journey of learning any new electronics platform starts with blinking an LED. This is popularly called as Hello world of Electronics. 
So, let us start with this new exciting Arduino learning journey.

Components Required: 
 2. 5mm LED (Any Color) 
3. 220Ω resistor 
4. Connecting wires
 LED Basics: LED stands for Light Emitting Diode. Diode is an electronics component which conducts current only in one direction and blocks in other direction. LED has two legs one is longer called Anode (+) and shorter called Cathode(-). So when positive voltage is applied to Anode and ground is applied to Cathode then LED starts conducting current and glows. And when connected in opposite direction, it stops conducting and not glow.




4.3 Interfacing: Here we have connected longer leg of LED to the digital Pin 4. But you can choose any other digital pin of your choice. The shorter leg of LED is connected to ground.


Before start coding let us understand the logic behind blinking LED. Blinking LED means turning LED on for few seconds and off for other few seconds. As we learnt in LED Basics, to turn LED on we need to apply positive voltage to long leg and short leg is already connected to ground. This could be done by making pin 4 high, and to turn LED off we need to make pin 4 low. That’s it… Here comes the LED blinking program as per the above logic.

void setup() 
{
 pinMode(4, OUTPUT); // initialize digital pin 4 as an output.
 }
 void loop()
 {
 digitalWrite(4, HIGH); // turn the LED on 
delay(1000); // wait for a second 
digitalWrite(4, LOW); // turn the LED off
 delay(1000); // wait for a second
 }
Now first check the code for any errors. This could be done by pressing verify button as shown below.


Now connect Arduino to PC with cable. Before uploading code to board we need to select the type of board and it’s port number. This could be done by clicking on Tools>>Board>>Arduino/Genuino UNO and to choose port click on Tools>>Port>>Select COM Port named Arduino/Genuino UNO


Now you are ready to upload the code. Now just click on Upload Button and wait till upload is complete. After completing upload LED should start blinking. For more fun try changing the delay on code and observe the changes in blinking rate.



No comments: