In this article, I will explain how to blink an LED in
Arduino Mega 2560.
Parts Of List:
- Arduino Mega 2560
- LED-3
- Bread Board
- USB Cable.
LED:
- Light Emitting Diode (LED) can emit light.
- The LED glows when the voltage is applied
Figure 1: LED
Connection: Take three LEDs and fix them in the Bread Board.
First LED connection:
- Positive pin = 13;
- Negative pin = Gnd.
Second LED connection:
- Positive pin = 12;
- Negative pin = Gnd.
Third LED connection:
- Positive pin = 11;
- Negative pin = Gnd.
Programming:
- int led1 = 13;
- int led2 = 12;
- int led3 = 11;
- void setup()
- {
- pinMode(13, OUTPUT);
- pinMode(12, OUTPUT);
- pinMode(11, OUTPUT);
- }
- void loop()
- {
- digitalWrite(13, HIGH);
- delay(1000);
- digitalWrite(13, LOW);
- delay(1000);
- digitalWrite(12, HIGH);
- delay(1000);
- digitalWrite(12, LOW);
- delay(1000);
- digitalWrite(11, HIGH);
- delay(1000);
- digitalWrite(11, LOW);
- delay(1000);
- }
Explanation:
- When the first LED is ON then automatically take the delay time.
- And the second LED is ON and finally the third LED is also ON.
- It can be repeatedly done.
Read more articles on Arduino: