Led Burning with Arduino

The simplest project arduino enthusiasts do when starting to learn is the application of led burning and extinguishing with Arduino. Now let's see the circuit installation diagram and then the Arduino LED combustion codes for this easy application. What is LED before that? Let's take a look at this.

What is LED?

LED is an abbreviation consisting of the initials light emitting diode. As the name suggests, led is a diode. As we know, the diode is a two-legged semiconductor circuit element that allows the current to pass in only one direction.

How does the LED work?

Like other diodes, the LED has two different types of semiconductor substances, p-type and n-type. The P-type semiconductor has positive load carriers, while the n-type semiconductor has negative load carriers. In this way, it is possible to pass electric current through the diode only in the direction of the cathode from the anode

Required Materials

  • Arduino Card
  • Any Led
  • 220-330 Ohm Resistance
  • Jumper and Breadboard
arduino led
Led

Circuit Diagram

Led Burning with Arduino
Circuit Diagram Led

Arduino Led Code

We transferred the pin number to which the ledin is connected to a variable called ledPin.
int ledPin=2;
void setup() {  
pinMode(ledPin, OUTPUT);
}
void loop() {
We powered the led-connected pine and held it for 1 second  
digitalWrite(ledPin, HIGH);
delay(1000);
We cut off the power to the pin to which led was attached and held it for 1 second  
digitalWrite(ledPin, LOW);
delay(1000);

HIGH Our LED will flash at 1 second intervals as the outputs give 5V, LOW Outputs 0V.

Extra: Using LED Driver

Shift Register Operating Logic

Although not much different from the 74HC595, as mentioned earlier, the HEF4094 integration is a shift register integration with 8-bit serial output controlled by 3 inputs. The 3 entries mentioned here are:

  • Serial Data Entry
  • Clock Input
  • Latch Input

The working logic is quite simple. First of all, we make the latch entry "0". This makes the system ready to read data. We give the data pin the value we want to be stored. When we send a clock pulse to the Clock pin, this data is written to the smallest bit. Next to the typing process, the remaining bits are deleted while the larger pine is scrolled. When 8 clock pulses are performed, the old 8-bit values are left, while the newly issued 8-bit data is stored. Then, when we make the latch pin "1", this 8-bit value is given to the output. With this animation, the basics of the shift-register method will be established. arduino led

Using Shift Register with Arduino

Arduino's own library contains the code "shiftOut" for Shift-Register integrations. But to understand the operating logic, let's first look at how to check without using this code. I used a regular LED but you can also use it with 1 digit 7 segment. arduino led

Arduino Code

int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
byte led = 0;
void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
}
void loop()
{
  led = 0;
  register_et();
  delay(200);
  for (int i = 0; i < 8; i++)
  {
    bitSet(led, i);
    register_et();
    delay(200);
  }
  for (int i = 8; i > = 0; i--)
  {
    bitClear(led, i);
    register_et();
    delay(200);
  }
}
void register_et()
{
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, LSBFIRST, led);
  digitalWrite(latchPin, HIGH);
}

Code Description

In the first part of our code, we defined our output pins, as we always do. We defined an 8-bit variable with leds name (variables of type byte are 8 bits in size). Each bit of this byte represents leDs that depend on the output of our shift register. Our register_eT function performs the necessary operations for shift register to work. by calling this function in our loop function, we call this function to transfer the changes we have made to the LED variable to our LEDs. In our loop function, we used two for loops. The first for cycle 00000001, 00000011, 00000111 each of the 8 bits in our LEDS variable by making it 1 in turn… it will allow us to obtain a pattern in the form of. After each bit is 1 (11111111), starting the second for cycle, this time by 0 to 01111111 the bits, 001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 pattern.

Diagram for 7-Segment 1 Digit

arduino led arduino led