We are putting together a little maker space and the main guy asked me to get his marque lights working.
There are 8 LEDs in each letter and 6 letters make up the word MAKERS.
I used adafruit"s lesson 4: "eight LEDs and a shift register to wire the shift registers and tested each letter separately.
The goal for now is to get the first letter M to scroll while the others letters stay off. one light, then two, then three as they chase each other around until they all eight are lit up.
Problem I'm having is the first LED in the M lights up, call it M1. Then the first LED in the A lights up A1. This continues until almost all the lights are lit up on both letters. I say almost because M8 lights up and then A goes out instead of lighting A8.
I can't seem to keep the second letter from lighting up.
Here's the program I wrote for it:
//Pin connected to ST_CP of 74HC595
int latchPin = 5;
//Pin connected to SH_CP of 74HC595
int clockPin = 6;
////Pin connected to DS of 74HC595
int dataPin = 4;
byte lets[] = {
B00100000, B00110000, B00111000, B00111100, B00111110, B00111111 };
byte leds[] = {
B00000001, B00000011, B00000111, B00001111, B00011111, B00111111, B01111111, B11111111 };
int n = 0;
void setup() {
//Start Serial for debuging purposes
Serial.begin(9600);
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
digitalWrite(latchPin, LOW);
for (int z = 0; z < 5; z++)
{
delay(1000);
shiftOut(dataPin, clockPin, LSBFIRST, 0);
Serial.print("z");
Serial.print(z);
}
//digitalWrite(latchPin, HIGH);
//digitalWrite(latchPin, LOW);
delay(1000);
shiftOut(dataPin, clockPin, LSBFIRST, leds[n]);
//delay(5000); //put here M on 1 sec both on 10 secs
digitalWrite(latchPin, HIGH);
delay(5000); //put here 5 seconds between M and A
//then both on 5
// until M7 when A doesn't come on
Serial.print(" n");
Serial.println (n);
//light (n);
n++;
if (n > 7)
{
n = 0;
}
} // end of loop
// serial monitor results:
// z0z1z2z3z4 n0
// z0z1z2z3z4 n1
// z0z1z2z3z4 n2
// z0z1z2z3z4 n3
// z0z1z2z3z4 n4
// z0z1z2z3z4 n5
// z0z1z2z3z4 n6
// z0z1z2z3z4 n7
// z0z1z2z3z4 n0
// z0z1z2z3z4 n1
// z0z1z2z3z4 n2
// z0z1z2z3z4 n3
// z0z1z2z3z4 n4
// z0z1z2z3z4 n5
// z0z1z2z3z4 n6
// z0z1z2z3z4 n7
The serial results seem fine. See anything I did wrong?