Not Quite Working
Sorry to sound like a broken
record but it is probably
something as simple as a
crossed wire.
17
CIRC-05
Code
(no need to type everything in just)
Not Working?
(3 things to try)
More, More, More:
More details, where to buy more parts, where to ask more questions.
http://tinyurl.com/dkjno3
Making it Better
The Arduino’s Power
LED goes out
This happened to us a couple
of times, it happens when the
chip is inserted backwards. If
you fix it quickly nothing will
break.
milliseconds to delay
Doing it the hard way:
//between LED updates
An Arduino makes rather complex actions very easy, shifting out data
for(int i = 0; i < 8; i++){
is one of these cases. However one of the nice features of an
changeLED(i,ON);
delay(delayTime);
Arduino is you can make things as easy or difficult as you like. Lets
}
for(int i = 0; i < 8; i++){
try an example of this. In your loop switch the line.
changeLED(i,OFF);
updateLEDs(i) -> updateLEDsLong(i);
delay(delayTime);
Upload the program and notice nothing has changed. If you look at
}
the code you can see how we are communicating with the chip one
bit at a time. (for more details http://tinyurl.com/3augzd )
And upload this will cause the lights to light up one after another and then
off in a similar manner. Check the code and wikipedia to see how it works,
Controlling Individual LEDs:
or shoot us an e-mail if you have questions.
Time to start controlling the LEDs in a similar method as we did in
CIRC02. As the eight LED states are stored in one byte (an 8 bit
More Animations:
value) for details on how this works try http://tinyurl.com/6vz53. An
Now things get more interesting. If you look back to the code from CIRC02
Arduino is very good at manipulating bits and there are an entire set
(8 LED Fun) you see we change the LEDs using digitalWrite(led, state), this
of operators that help us out. Details on bitwise maths (
is the same format as the routine we wrote changeLED(led, state). You can
http://tinyurl.com/br8dd )
use the animations you wrote for CIRC02 by copying the code into this
sketch and changing all the digitalWrite()'s to changeLED()'s. Powerful?
Our implementation.
Very. (you'll also need to change a few other things but follow the compile
Replace the
loop()
code with
int delayTime = 100; //the number of
errors and it works itself out)
Frustration?
Shoot us an e-mail, this circuit
is both simple and complex at
the same time. We want to
hear about problems you have
so we can address them in
future editions.
Download the Code from ( http://tinyurl.com/cv4fjt )
(copy the text and paste it into an empty Arduino Sketch)
//Pin Definitions
//The 74HC595 uses a protocol called SPI
//Which has three pins
int data = 2;
digitalWrite(latch, LOW);
int clock = 3;
int latch = 4;
//Pulls the chips latch low
shiftOut(data, clock, MSBFIRST, value);
void setup() //runs once
//Shifts out 8 bits to the shift register
{
pinMode(data, OUTPUT);
pinMode(clock, OUTPUT);
digitalWrite(latch, HIGH);
pinMode(latch, OUTPUT); }
//Pulls the latch high displaying the data
}
void loop() // run over and over again
{
---------- More Code Online ----------
int delayTime = 100;
//delay between LED updates
for(int i = 0; i < 256; i++){
updateLEDs(i);
delay(delayTime); }
}
/*
* updateLEDs() - sends the LED states set
* in value to the 74HC595 sequence
*/
void updateLEDs(int value){
16
CIRC-05
What We’re Doing:
.:8 More LEDs:.
.:74HC595 Shift Register:.
Time to start playing with chips. Or integrated circuits (ICs) as they like to be
called. The external packaging of a chip can be very deceptive for example the
chip on the Arduino board (a micro controller) and the one we will use in this
circuit (a shift register) look very similar but are in fact rather different, for
example the price of the Atmega chip on the arduino board is a few dollars while the
74hc595 is a couple dozen cents. It's a good introductory chip, and once your comfortable playing around with it and its
datasheet (available online http://tinyurl.com/pr42xe ) the world of chips will be your oyster. The shift register (also called
a serial to parallel converter), will give you an additional 8 outputs (to control LEDs and the like) using only three arduino
pins. They can also be linked together to give you a nearly unlimited number of outputs using the same four pins. To use
it you “clock in” the data and then latch lock it in (latch it). To do this you set the data pin to either HIGH or LOW, pulse
the clock, then set the data pin again and pulse the clock repeating until you have shifted out 8 bits of data. Then you
pulse the latch and the 8 bits are transferred to the shift registers pins. It sounds complicated but is really simple once
you get the hang of it.
(for a more in depth look at how a shift register works visit: http://tinyurl.com/56uvv7 )
The Circuit:
Wire
Shift Register
74HC595
x1
560 Ohm Resistor
Green-Blue-Brown
x8
2 Pin Header
x4
CIRC-05
Breadboard sheet
x1
Parts:
Red LED
x8
Schematic:
L
E
D
re
si
st
o
r
(5
6
0
o
h
m
)
g
n
d
(g
ro
u
n
d
)
(-
)
pin
4
pin
3
pin
2
0
1
2
3
4
5
6
7
data
clock
latch
+5V
gnd
74HC595
+5 volts
There is a half moon
cutout, this goes at the top
.:download:.
breadboard layout sheet
http://tinyurl.com/d8xepz.
.:view:.
assembling video
http://tinyurl.com/c2enkv
The Internet