Blinking LED

  Interfacing Light Emitting Diode (LED)- Blinking LED

Blinking LED

The following is a list of the parts an LED uses to blink:
  • 1* Arduino UNO board.
We can use any version of the UNO board, such as UNO R3, etc. We can also use other types of Arduino boards, such as Arduino Zero, Arduino Micro, etc.
  • 1* Breadboard.
  • 2* Jump wires.
  • 1* LED.
  • 1* Resistor of 220 Ohm.
Any resistor up to 470 ohms can be used. Depending on the needs of our circuit, we can also utilize resistors of different values. The value typically shouldn't go over the permitted forward current.

Principle:
  • In this lesson, we'll program the Arduino's high-level (+5V) and low-level (0V) GPIO outputs before programming an LED attached to the GPIO to flicker at a set frequency.
What is the LED?
  • The light emitting diode is referred to as an LED. Gallium phosphide and gallium arsenide semiconductor materials are typically used in its construction.
  • A positive electrode and a negative electrode make up the LED. Only when a forward current flows through does it turn on, and it can flash red, blue, green, yellow, etc. The material from which the light is made determines its colour.


What is resistor?
  • The resistor's primary job is to restrict current flow. The resistor is represented by the letter "R" in the circuit, and its unit is the ohm ().
  • This experiment makes use of a band resistor. It is a resistor with a surface painted a certain colour, allowing for easy identification of the resistance.
  • There are two methods for connecting LED to pins of an Arduino board:


  • The anode of the LED is linked to the GPIO on the Arduino through a resistor, while the cathode is connected to ground, as shown in the schematic diagram (GND). 
  • The LED is on when the GPIO output is at a high level; it is off when it is at a low level.
  • The following formula is used to determine a current-limiting resistor's resistance: Given that an LED requires 5–20mA of current to turn on and that the Arduino UNO's GPIO output voltage is 5V, we can calculate the resistance as follows:
  • R = U/I = 5V/(520mA) = 2501k
  • Here, we utilize a 220 ohm resistor because an LED is a resistor by nature.


  • The anode of the LED is linked to VCC(+5V), while the cathode is connected to the GPIO on the Arduino, as shown in the schematic picture above. The LED is on when the GPIO output is low; it is off when the GPIO output is high.
  • The experiment is based on technique 1: control an LED using Arduino board pin D8. The LED will light on when D8 is configured to output at a high level. Next, wait for a while. 
  • The LED is then turned off by programming D8 to output low level. You can then get a blinking LED by repeating the aforementioned procedure. 3.
Key functions:
setup()
The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using loop()
  • After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. 
  • Use it to actively control the Arduino board.
pinMode()
  • Configures the specified pin to behave either as an input or an output.
  • As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP.
  • Additionally, the INPUT mode explicitly disables the internal pullups.
digitalWrite()
  • Write a HIGH or a LOW value to a digital pin.
  • If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
  • If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor.
delay()
  • Pauses the program for the amount of time (in millisecond’s) specified as parameter. (There are 1000 milliseconds in a second.)
Procedure:
Step 1: Build the circuit.
Step 2: Program
Step 3: Compile the program and upload to Arduino UNO board. Now you can see the LED blinking.

Code:-

void setup ()  
{  
pinMode ( 8, OUTPUT);  // to set the OUTPUT mode of pin number 8.  
}  
void loop ()  
{  
digitalWrite (8, HIGH);   
delay(1000);  // 1 second = 1 x 1000 milliseconds  
digitalWrite (8, LOW);  
delay(500);  // 0.5 second = 0.5 x 1000 milliseconds  
 



Youtube For Videos Join Our Youtube Channel: Join Now

Post a Comment

Previous Post Next Post