Arduino Tutorial 2 : External LED Blink

Hello all ! Today in this blog we will discuss about how to control an external LED using Arduino through programming. Arduino is an open source electronic platform based on easy to use hardware and software.

Please support us on YouTube also. Like Share and Subscribe to our channel : https://youtube.com/c/RatnasRoboLab

Components

Code

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Code to Note

pinMode(2, OUTPUT) – You have to tell ARDUINO that PIN2 is used as Output or Input. so, here we used the built in function called pinMode().

digitalWrite(2, HIGH) – When you are using PIN2 as output, you can command it to HIGH or LOW.

Result

In this program the external LED turns ON for one sec and turns OFF for one sec repeatedly. Similarly we can also reprogram the ARDUINO and change the rate at which it blinks.

Further Readings

If you liked this article, then please subscribe to our YouTube Channel. You can also find us on InstagramFacebook and Twitter.

READ – CONNECT – BOOST – CREATE