0
\$\begingroup\$

A prenote; I'm not sure if this falls more into electronics or Arduino, but I think Shift Registers are more so electronic and binary related.

I'm using a single SN74HC595N shift register connected to my Arduino Uno. I'm using Arduino's shiftOut function, but when I send a byte, for example, 11111111, Only Output1 and Output7 are active. I also tried a few different ones, such as01010101 and still, the output seemed nothing like what I would expect (Except 00000000 which did as I expected, and turned all the LEDs off). Here is a chart of the connections to the Arduino:

Connection Table

~the output pins are connected to 3mm LED's through resistors; Everything is directly wired, but VCC is demodulated with two 0.1uF, and a 10uF capacitor, that connects to GND to filter any high frequencies and smooth out the input

And my simple code:

int latchPin = 12;
int clockPin = 11;
int dataPin = 13;


void setup(){
    pinMode(latchPin, OUTPUT);
    pinMode(dataPin, OUTPUT);
    pinMode(clockPin, OUTPUT);

    digitalWrite(latchPin, LOW);
    digitalWrite(clockPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, 1111111);
    digitalWrite(latchPin, HIGH);
    digitalWrite(clockPin, HIGH);

}

void loop(){

}

I am brand new to shift registers (and unfamiliar with bytes) so I apologize for any incompetence, and thank you for the help!

EDIT: Now, when I send 11111111, I get pins 0, 1, 2, 3, and 7 to turn on. I confirmed this with my multimeter, the active pins read 4.85 volts, whereas the deactivated pins read 0 volts.

\$\endgroup\$
  • \$\begingroup\$ You probably need to show your connections, how power is routed, is there any bypass caps, how clocks etc. are wired. \$\endgroup\$ – Ale..chenski May 15 '18 at 1:01
2
\$\begingroup\$

You need to provide a byte (uint8_t) for the data to be shifted out. Your 11111111 is being interpreted as a decimal literal so you're getting some part of that. I would expect the number 11111111 = 0xA98AC7 to come out as 0xC7 , which does not exactly match what you are seeing- so perhaps there is something else wrong in addition.

Try shiftOut(dataPin, clockPin, LSBFIRST, 0xFF); for all on.

If you prefer binary to hex, you should be able to use 0b11111111 .. that binary format is supported by GCC and thus Ardunio.

\$\endgroup\$
  • 1
    \$\begingroup\$ It was the b in 0b that fixed it. Thanks a lot! \$\endgroup\$ – Carter F May 26 '18 at 15:31
0
\$\begingroup\$

You need to make sure that the sequence of transitions follows the timing diagram for SN74HC595N shift register:

enter image description here

Right now I am not sure which timing diagram is produced by your code.

The other potential concern might be with your physical wiring (which you didn't reveal). wire impedance mismatches can produce ringing which might cause "double clocking" and false shifts with wrong data.

A bit of advice: use the exact spelling of signal names in your code per IC datasheets, so it will be easy to follow transitions with datasheet timing diagrams and not looking up mentally signal names across two look-up tables.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.