shift register confusion

I have two 74HC595’s daisy chained togther - I think. All I want to do is light three LEDs on either end. The darn solution escapes me.

Any help would be appreciated.

int latchPin=11;
int clockPin=9;
int dataPin=12;
int dt=250;

byte LED1s=0B1110000000000111;


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);


digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, MSBFIRST, LED1s);
digitalWrite(latchPin, HIGH);

}

void loop() {
  // put your main code here, to run repeatedly:

}

tperry724:

byte LED1s=0B1110000000000111;

hmmm.... using 'byte' for a 16-bit value!

also I suggest you look up the 0B notation (Integer Constants - Arduino Reference) and the datatype 'shiftOut' takes (shiftOut() - Arduino Reference)

hope that helps...

I look the long way to grandma's house but it works....

int latchPin=11;
int clockPin=9;
int dataPin=12;
int dt=500;

byte LED1A=0B00000000;
byte LED1B=0B10000000;

byte LED2A=0B00000000;
byte LED2B=0B01000000;

byte LED3A=0B00000000;
byte LED3B=0B00100000;

byte LED4A=0B00000000;
byte LED4B=0B00010000;

byte LED5A=0B00000000;
byte LED5B=0B00001000;

byte LED6A=0B00000000;
byte LED6B=0B00000100;

byte LED7A=0B00000000;
byte LED7B=0B00000010;

byte LED8A=0B00000000;
byte LED8B=0B00000001;

byte LED9A=0B10000000;
byte LED9B=0B00000000;

byte LED10A=0B01000000;
byte LED10B=0B00000000;

byte LED11A=0B00100000;
byte LED11B=0B00000000;

byte LED12A=0B00010000;
byte LED12B=0B00000000;

byte LED13A=0B00001000;
byte LED13B=0B00000000;

byte LED14A=0B00000100;
byte LED14B=0B00000000;

byte LED15A=0B00000010;
byte LED15B=0B00000000;

byte LED16A=0B00000001;
byte LED16B=0B00000000;


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED1A);
shiftOut(dataPin, clockPin, LSBFIRST, LED1B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED2A);
shiftOut(dataPin, clockPin, LSBFIRST, LED2B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED3A);
shiftOut(dataPin, clockPin, LSBFIRST, LED3B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED4A);
shiftOut(dataPin, clockPin, LSBFIRST, LED4B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED5A);
shiftOut(dataPin, clockPin, LSBFIRST, LED5B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED6A);
shiftOut(dataPin, clockPin, LSBFIRST, LED6B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED7A);
shiftOut(dataPin, clockPin, LSBFIRST, LED7B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED8A);
shiftOut(dataPin, clockPin, LSBFIRST, LED8B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED9A);
shiftOut(dataPin, clockPin, LSBFIRST, LED9B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED10A);
shiftOut(dataPin, clockPin, LSBFIRST, LED10B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED11A);
shiftOut(dataPin, clockPin, LSBFIRST, LED11B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED12A);
shiftOut(dataPin, clockPin, LSBFIRST, LED12B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED13A);
shiftOut(dataPin, clockPin, LSBFIRST, LED13B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED14A);
shiftOut(dataPin, clockPin, LSBFIRST, LED14B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED15A);
shiftOut(dataPin, clockPin, LSBFIRST, LED15B);
digitalWrite(latchPin, HIGH);
delay (dt);

digitalWrite(latchPin,LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED16A);
shiftOut(dataPin, clockPin, LSBFIRST, LED16B);
digitalWrite(latchPin, HIGH);
delay (dt);

}

Thank you for the help.

Tony

Sure did. LEDxA, LEDxB could have gone into an array, then used a for loop to sequence thru the array.
Would have made loop() quite a bit shorter.
The array would still be needed. Easier to see what's going on vs trying to manipulate all the data back & forth.

CrossRoads,

Don’t suppose you could point me in the right direction with a snippet of code and an explanation as to how it works? I’m learning but still a newbie.

Best,

Tony