Saturday 18 February 2017

Getting started with Arduino - LED Blink Digital Output

Today we will start our Arduino tutorial with a very basic thing. There are many coders around the world who write codes to develop some cool softwares to run on computers, smartphones and tsablets. But there are very few who writes code to control hardware using their program. Writing a general basic program won't do that. You need some special devices called microcontrollers and microcomputers with GPIO pins which can control digital devices, read sensor data and perform different actions.
Arduino is most popular open-source board microcontroller. It has a number of digital, analog PWM pins which will serve our purpose. Here we will use Arduino to make LED blink every second.

Hardware Required

  • Arduino UNO
  • Breadboard
  • LED - We are using a red LED here
  • 220ohm resistor
  • Some Jumper wires
Build the circuit
  • Connect a M-M jumper from GND to breadboard
  • Connect GND of breadboard to -ve terminal of LED via resistorto avoid burning it.
  • Connect +ve of LED to pin3 of Arduino

Write the code/sketch
  • Open Arduino IDE and then go to Tools > Board > Arduino Uno. 
  • And also select Tools > Port > Arduino COM Port (COM3/COM4 like)
const int LED = 3;  //Pin to which LED is connected to Arduino

void setup() {
  pinMode(LED, OUTPUT);  //We would see output from this pin
}

void loop() {
  digitalWrite(LED, HIGH);  //Set HIGH voltage
  delay(1000);             
  digitalWrite(LED, LOW);  //Set 0 voltage
  delay(1000);
}
Upload sketch to Arduino and see.


Cheers. Have Fun