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 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
/*
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:
0 Comments