I am trying to build a traffic control system for my model train to have a road intersection. I am trying to use two shift registers. As I understand it, with the 74HC595's it takes serial data in one bit at a time and outputs the data in parallel. So I should be able to put in the binary pattern (LSBFIRST) and it should light up the LED's in that pattern. Now when I input my binary pattern, EX, 000001000000 it turn on pin 15 on the first register and pin 15 on the second register which means having two led's on at the same time.
Is there a trick to using these registers?
Here is the code I am using.
// Instlize the output pins on the Ardunio Mega
int latchPin = 11; // Asigns pin 12 of the IC to pin 11 on the Ardunio.
int clockPin = 9; // Asigns pin 11 of the IC the pin 9 on the Ardunio.
int dataPin = 12; // Assigns pin 14 of the IC to pin 12 on the Ardunio.
int dtrg = 500; // Set the delay timing for the Red and Green lights.
// Controls the light patterns with BINARY numbers.
int LEDs = 0b0000010000000;//Sets the red and green light cycle pattern in BINARY.
void setup() {
pinMode(latchPin, OUTPUT); // Sets pin 12 on the IC 74HC595 to pin 11 on the Ardunio.
pinMode(clockPin, OUTPUT); // Sets pin 11 on the IC 74HC595 to pin 9 on the Ardunio.
pinMode(dataPin, OUTPUT); // Sets pin 14 on the IC 74HC595 to pin 12 on the Ardunio.
}
// Displays the first Red and Green cycle.
void loop() {
digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin,LSBFIRST, LEDs);
digitalWrite(latchPin,HIGH);
delay(dtrg);
Any help would be welcome.
}