Arduino - Led Blink
This is a simple project using Arduino. It would enrich your knowledge about Arduino. You’re going to program your first Arduino project starts with LED.
Components required
You will need following components -
- Breadboard x 1
- led x 1 ( any color )
- 220Ω / 330Ω Resistor x 1
- Jumper x 2 ( Male - Male)
- Arduino Uno x 1 ( Any Arduino board can be used )
Procedure
Follow the circuit diagram and hook up the components on the breadboard as shown in the image given below.
Connect the positive terminal of the LED to 8th pin in Arduino board after adding resistor to negative terminal of the LED then connect the end of the resistor to GND of the Arduino board.
Note − To find out the polarity of an LED, look at it closely. The shorter of the two legs, towards the flat edge of the bulb indicates the negative terminal.
Sketch
Open the Arduino IDE software on your computer. Coding in the Arduino language will control your circuit. Open the new sketch File by clicking New and save it by pressing Ctrl + Shift + S.
Arduino Code
void setup() {
pinMode(8,OUTPUT);
}
void loop() {
digitalWrite(8,HIGH);
delay(1000);
digitalWrite(8,LOW);
delay(1000);
}
Download code by pressing this link.
Code to Note
pinMode(2, OUTPUT) − Before you can use one of Arduino’s pins, you need to tell Arduino whether it is an INPUT or OUTPUT. We use a built-in “function” called pinMode() to do this.
digitalWrite(2, HIGH) − When you are using a pin as an OUTPUT, you can command it to be HIGH (output 5 volts), or LOW (output 0 volts).
Result
You should see your LED turn on and off. If the required output is not seen, make sure you have assembled the circuit correctly, and verified and uploaded the code to your board.
Arduino Code
void setup() {
pinMode(8,OUTPUT);
}
void loop() {
digitalWrite(8,HIGH);
delay(1000);
digitalWrite(8,LOW);
delay(1000);
}
Download code by pressing this link.
Code to Note
Result
You should see your LED turn on and off. If the required output is not seen, make sure you have assembled the circuit correctly, and verified and uploaded the code to your board.
Hi
ReplyDelete