Controlling 8 BIT SMD LED Array with ARDUINO

This is our very first intractable, we want to control 8 bit smd led array with arduino.

Step 1:
Materials Required
1.     Arduino (We use UNO)
2.     8 Bit Smd Led Array
3.     Jumper wires Male - Female

Software Required
1.     Arduino IDE (We use NSight Eclipse)

Circuit Diagram
  



Step 2:
Uploading Arduino Program

Code:

#include<avr/io.h> 

int main (void)

{
  unsigned char input1, input2;
  DDRB = DDRB | 0b00001111;         // Make pins B3 to B0 as output
  DDRB = DDRB & 0b11001111;        // Make pins B5 and B4 as input
while (1)
{
  // Take care of the inputs
  input1 = PINB & 0b00010000;          // Read pin B4 as input1
  input2 = PINB & 0b00100000;          // Read pin B5 as input2
  // Implement the 2:4 decoder as output
  if (input2 != 0 && input1 != 0)
  {
  // Turn on LED1 only
    PORTB = PORTB & 0b11110000;// Turn off all LEDs first
    PORTB = PORTB | 0b00000001;// Turn on LED1
  }
  else if (input2 != 0 && input1 == 0)
  {
    PORTB = PORTB & 0b11110000;// Turn off all LEDs first
    PORTB = PORTB | 0b00000010;// Turn on LED2
  }
  else if (input2 == 0 && input1 != 0)
  {
    PORTB = PORTB & 0b11110000;// Turn off all LEDs first
    PORTB = PORTB | 0b00000100;// Turn on LED3
  }
  else if (input2 == 0 && input1 == 0)
  {
    PORTB = PORTB & 0b11110000;// Turn off all LEDs first
    PORTB = PORTB | 0b00001000;// Turn on LED4
  }
  else
  {
  	PORTB = PORTB & 0b11110000;// Turn off all LEDs first
  }
}

return 0;

}

Picture of the completed hardware in operation


Finally, now we can see Led acting like what program we upload in Arduino.

Comments

Popular posts from this blog

Solution - Timus Problem 1293. Eniya

Solution - Codeforces Problem 327B - Hungry Sequence

Solution - Timus Problem 1409. Two Gangsters