As a newbie, I'm learning and trying to figure out what is wrong here.
I made a simple circuit with 4 red LED and 4 blue LED, connected with a 74HC595N shift register.
I am not quite sure how the shift register writes his bits to the Q outputs. But when I use this MSBFIRST, I would expect that the first bit that will be send to the first output (Q0) is going to be a 0, followed by another 0 (to Q1) and then a 1 (to Q2). So I expect that my third LED will lit up. Still it is the second LED (on Q1) that is lit!
I do understand that this is the order of bits sending out, and when I change the parameter to LSBFIRST, I see that my project is mirrored. But it sounds just not logical in my head.. Will the shift register store its bits starting for Q0 to Q7? Or first store it from Q7 to Q0?
Many thanks!
int latchPin=11;
int clockPin=9;
int dataPin=12;
byte LEDs=B00100010;
void setup() {
pinMode(latchPin,OUTPUT);
pinMode(dataPin,OUTPUT);
pinMode(clockPin,OUTPUT);
}
void loop() {
digitalWrite(latchPin,LOW);
shiftOut(dataPin,clockPin,MSBFIRST,LEDs);
digitalWrite(latchPin,HIGH);
}
actually the higher bit will go throu every register (Q0 to Q7) before stops at Q7 and therefore will be lost if you send more than an octet to the multiplexer.
I want to propose you to check (certainly "again") your connection from Led to multiplexer.
Just to make the big boy, here is an example I used on UNO. It is designed to reproduce, with 8 red led, the "K2000" effect (yes, I am a boomer)
note the cleaner, not the clearer, but I know it works. If you see led were jumped in the pattern, look at the wiring.
The data sheet for the 74HC595 shows the input (pin 14) going to QA (Q0) first, QA is fed to QB (Q1), etc, so that the first bit the arduino sends will be in Q7, the last bit in Q0.
The 74HC595N shifts left so the Arduino wants to shift MSB first. Assume you are shifting 1 bit, a B10000000 into the 74HC595N. The first shift will put it on Q0, the second on Q1 and the eights on Q7 (that is 8 shifts as zero is a number). If you shift LSB first you will wind up with 00000001B in the 74HC595N. Hopefully this helps.
The strobe just shows to the world what is in the internal registers. The concern here is (see the shift examples in post #4) does the '1' bit end up in LSB or MSB position inside the SR?