- Arduino UNO
- USB cable
- Resistors – 220 ohm(depends on the color of led)
- Connecting wires
You can purchase these in the following online store http://embeddedstore.in/.
LED is a light emitting diode i.e longer terminal is anode or positiveand shorter terminal is cathode or negative.
pin 7 -> one end of resistor
other end of the resistor -> anode
cathode – GND
pinMode(7,OUTPUT); // assigning 7th pin as output pin, hence it can be used as output in entire function of program
digitalWrite(7,HIGH); // This allows to supply 5volts in 7th pin
delay(500); // hold the previous condition to execute for 0.5 seconds
digitalWrite(7,LOW); // This allows 0volts in 7th pin
Compiling the Program: Click on the tick symbol on top left corner and for burning perform the following steps:
- Goto -> tools -> Board -> arduino uno
- Goto tools -> port -> select the respective port that has been detected in device manager as explained driver installation step.
Now click the arrow symbol next to the tick and wait for the compilation. The size of the program would appear in command window which appears as black in lower part of IDE.
That’s it……NOW YOU’RE A VIRGIN ARDUINO USER. Let’s introduce you to ‘switch’ and more programming statements .
press ctrl+N which will create new workspace and give the connections as per in circuit diagram
pinMode(8,OUTPUT); //led1 is connected
pinMode(9,OUTPUT); //led2 is connected
pinMode(2,INPUT); //switch is connected
if(digitalRead(2==HIGH)) // when swtich is pressed
digitalWrite(8,HIGH); //led1 is on
digitalWrite(9,LOW); // led2 is off
Serial.println(“switch is pressed”); //displays in serial monitor
else // when switch is not pressed
digitalWrite(8,LOW); //led1 is off
digitalWrite(9,HIGH); //led2 is on
Burn the program as mentioned earlier. We are going to interface with serial monitor. This can be seen either by pressing ctrl+shift+M or the icon which appear as lens with an box at top extreme right side of IDE. Once the switch is pressed the message will be appear and led1 will on and led2 will be off for 2 seconds.
Here we complete with all the basics of arduino which includes digital values alone and in next tutorial we will be handling with sensors. All doubts , positive comments and criticisms are most welcome.
Article was written by Bala Narayana (Facebook – Bala Shocks)