Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

Blinking LED with Arduino

Blinking LED with Arduino





Blinking LED with Arduino
 

A light-emitting diode (LED) is a semiconductor light source that emits light when current flows through it. LEDs are used in many electronic devices as indicator lamps, in automobiles as rear-window and brake lights, and on billboards and signs as alphanumeric displays or even full-colour posters.

In this tutorial i would explain how to interface the Arduino UNO with LED.


There are two ways of connecting the LED with Arduino which are:

  • Current sinking mode 
  • Current sourcing mode

In current sinking mode, current flows from the power supply (+5V) through a resistor and the LED itself to the I/O (Input/Output) pin of the microcontroller as shown in the schematic diagram below. In order to turn ON the LED in this mode, a logic Zero (i.e. a logic LOW) should be sent to the I/O pin and in order to turn OFF  the LED, a logic One (i.e. a logic HIGH) should be sent to the PIC MCU.



Fig: Current Sinking Mode


In current sourcing mode, current flows out of the PIC MCU through a resistor and to the LED itself as shown in the schematic diagram below.  In order to turn ON the LED in this mode, a logic One (i.e. a logic HIGH) should be sent to the I/O pin and in order to turn OFF  the LED, a logic Zero(i.e. a logic LOW) should be sent to the PIC MCU.




Fig: current sourcing mode


In this tutorial we will consider the Current Sourcing mode but Note that in order to work with the current sinking mode, one has to adjust the Logic sent to the I/O pin in the code as well as the schematic.


We would be using I/O Pin8 of the Arduino UNO.

Components Required:

  • Arduino UNO
  • 330R resistor
  • LED
CODE


/*

  Name     : BLINKING LED WITH ARDUINO

  Author   : DANIEL OLUWOLE

           : (C) 2020 DANITRONICS.

           : danitronics7@gmail.com, danieloluwole51@yahoo.com

           : Mobile: +234 8188508765.


*/

// The setup function runs when you press reset or power the board

int LED_PIN = 8;     //variable to hold status of pin 8  of Arduino

void setup()

{

pinMode(LED_PIN, OUTPUT);     // initialize digital pin 8 as an output.

 }

// the loop function runs over and over again forever

void loop()

{

digitalWrite(LED_PIN, HIGH);   // turn the LED ON (HIGH is the voltage level)

delay(1000);              // wait for a second

digitalWrite(LED_PIN, LOW);    // turn the LED OFF by making the voltage LOW

delay(1000);              // wait for a second

NEXT POST:

Read Switch with Arduino

Post a Comment

0 Comments

Ad Code

Responsive Advertisement