The purpose of this investigation is to utilize the 'shit register' and create 8 outputs.
Equipment
- 8 x Red LEDs
- 8 x 330 Ohm Resistors
- 1 x Shift Register
- 19 x Wires
- 1 x Breadboard
- 1 x Breadboard sheet
- 1 x Arduino Uno
Program Details
The breadboard sheet for this circuit is probably the most intimidating one, however it is simply a matter of strategy and patience. You must take your time. See the Tips section. This circuit utilizes wiring, LEDs and resistors from the past circuit. The shift register is simply a matter of aligning it in the right hole. After assembling our circuit and checking over the resistors numerous times, we programmed.
The program is understandable once you understand the concept behind the shift register. This shift register recieves data of what to do from each of the 8 pins, in binary language, then outputs it to the LED. Only certain LEDs turn on, creating a blinking pattern. First the variables, and delay times are set. Then the program starts repeating the function of turning on certain lights. The number i, determines which LEDs turn on as it is sent to the 'updateLEDs()' function. The value of i, is assigned in binary to the shift register, and that determines which LED turns on. In confidence we uploaded this program and watched as only two LEDs turned on. We checked the wires and resistors, another group did as well. Until finally we realized the LEDs were the problem. We overlooked placing the LEDs in correct orientation. The +/- pins of the LED were placed into the breadboard randomly. After fixing this, our circuit worked fine. The LEDs seemed to blink in a random fashion, but after looking at the program closely, we realized the program was following a set of 255 combos in binary that is sent to the shift register. Unfortunately, there was not enough time to obtain a picture of the working circuit. However, here are pictures of the assembled, partially working circuits.
Results
The results are not that exciting in proportion to all the assembly, however the phenomenon behind it is quite astonishing. The one shift register provides the ability to control 8 outputs, using 255 different combinations! Note, the pattern is not random, it corresponds to the value of i, in binary, which spans 8 bits. If everything is simply wired the right way, the 8 LEDs should turn on and off as instructed.
Tips
The ultimate advice with this circuit is to take your time, because with this many equipment, it is too easy to plug something wrong, miss something, etc. First count out the correct number of pieces. Then attach them to the breadboard one by one. For instance, all the wires, then all the LEDs, etc. The advised order is the shift register first, because it is lowest to the breadboard, then LEDs because it'd be a hassle attaching it under all that wire, then the wires. And finally the resistors, because they border everything else. Also make sure one pair of hands tends to the breadboard at a time, it is less confusing and much more efficient that way.
Next Steps & Associated Program Modifications
Another way to control these pins is to turn them on one after another, then off one after another, similar to CIRC-02. In this code, the 'loop()', is replaced with the 'repeat function', where i counts to 8, using the 'changeLED(i,state)' function to turn the LEDs 'ON' then 'OFF'. See below.
int data=2;
int clock=3;
int latch=4;
//the pins above are associated to the shift register
void setup()
{ //the introduced pins will be used as outputs
pinMode (data, OUTPUT);
pinMode (clock, OUTPUT);
pinMode (latch, OUTPUT);
}
void loop()
{
changeLED(int led, int state); //repeatedly run this function
}
void changeLED(int led, int state) //function which turns the LEDs on and off
{
int delayTime=100;//delay time between each time function is repeated
for (int i=0; i<8; i++)//pins 0-7, so this is repeated until i is less than 8
//which is 7
{
changeLED (i,1); //turns the appropriate LED on, similar to HIGH
delay(delayTime); //delayed by 100ms before repeating
}
for (int i=0; i<8; i++)//for pins 0-7
{
changeLED (i,0); //turns the LED off, similar to LOW
delay(delayTime); //delayed by 100ms before repeating
}
}
References
1. http://oomlout.com/a/products/ardx/circ-05/
2. Spark Fun Inventor's Guide
No comments:
Post a Comment