Monday 17 October 2011

CIRC-05 - 8 More LEDs

Purpose:
To creates an 8 Bit binary timer using the 74HC595 Shift Register.

Equipment:

  • 1x Breadboard
  • 1x Arduino Uno
  • 8x LEDs
  • 8x 330 ohm Resistor
  • 1x Shift Register
  • Too many wires to count


Reference:
http://www.oomlout.com/a/products/ardx/circ-05

Program Details:
This experiment introduces one new piece of hardware, which is the shift regiester. A shift Register is a complex circuit, which is integrated into a chip shape. This is done so they take up less space, and save the time and resources actually having to build the circuit yourself. In this case our shift register takes in data. clock, ground, and voltage; and outputs from 7 different areas and ground.

The programming part of this experiment introduces assigning ints values of HIGH or LOW. This can be done because HIGH means 1, and LOW means 0. This program also introduces a new method called shiftOut(pin, pin, MSBFIRST, int); This method is the simple way to send Arduino the 8 bit data which it needs to display.

Finally putting this circuit together was very simple, but there were a lot of wires so it was easy to loose track. First connect the 5V to the 16th port (VCC), and the 8th port to ground. Port 11, 12, and 14 are for Clock(3), Latch(4), and Data(2). Then connect wires from Q0 - Q7 to the 8 LEDs, all of which should be parallel to one another, not in sequence. Make sure these LEDs are grounded, and have 330 ohm resistors to prevent the LEDs from receiving too much voltage.

Time to Complete:
20 minutes to build, 10 minutes to code.

Results:
All of the LEDs lit up in a consistent pattern. Most likely was counting like it was meant too, but cannot confirm as i cannot count in Binary.


Photo:


Tips:
Color coding the wires is vital for this project. But because of the shear amount of wires required, you might run out of a certain color. So make sure you keep your wires in order and track which one goes where.

Program Modification:
Very similar to the one found on:
http://www.oomlout.com/a/products/ardx/circ-05

The only difference is I removed the methods changeLED(int a, int b) and updateLEDsLong(int a). This is because these two methods were never called upon, so I found it a bit confusing to have them linger around without any purpose.

I also used the int ON and int OFF whenever it asked for HIGH or LOW. This is because i wanted to check to see how it worked.

Program:



int data = 2;
int clock = 3;
int latch = 4;                                      //initializes the pin# for the three inputs which the shift register takes

const int ON = HIGH;                       //Gives ON value of 1
const int OFF = LOW;                      //Gives OFF value of 0

void setup()                                       //Sets pins 2,3,4 for OUTPUT
{
   pinMode(data, OUTPUT);
   pinMode(clock, OUTPUT);
   pinMode( latch, OUTPUT);
}

void loop()
{
    for(int i = 0; i < 256; i++)               //repeats 256 times
    {
        updateLEDs(i);                         //Calls the method updateLEDs(int a) and gives it the value of the loop#
        delay(100);                                //Tenth of a second delay
    }
}

void updateLEDs(int value)
{
    digitalWrite(latch, OFF);                                  //Latch doesn't receive voltage(LEDs stop blinking)
    shiftOut(data, clock, MSBFIRST, value);         //Gives new set of data (Latch must be off)
    digitalWrite(latch, ON);                                   //Latch revives Voltage again(LEDs blink again)
}

    


No comments:

Post a Comment