1
Hello
I’m trying to light the led 1 that is in the pin 1 of 74HC595 and the rest are erased and then erase the led 1 and light only the led 2 that is in the pin 2 of 74HC595, but the problem I’m having is that all the leds stay lit together, which may be wrong ?
#define latchPin 5
#define clockPin 6
#define dataPin 4
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
digitalWrite(latchPin, HIGH);
shiftOut(dataPin, clockPin, LSBFIRST, 0b10000000);
digitalWrite(latchPin, LOW);
delay(1000);
digitalWrite(latchPin, HIGH);
shiftOut(dataPin, clockPin, LSBFIRST, 0b01000000);
digitalWrite(latchPin, LOW);
delay(1000);
}
Thank you
This depends a lot on how the 74HC595 is connected to the Arduino. Being a serial/parallel converter, it is difficult to answer without the diagram. Questions about hardware are not in the scope of the site, but in case maybe the diagram serves to analyze the software part.
– Bacco
An attempt would be to use a
digitalWrite(clockPin, LOW)
before theshiftOut
, in case the 74hC595 clock operates on the signal rise.– Bacco
Another thing, depending on how you turned on the 74HC595, the correct sequence would be
latchPin -> LOW
,shiftOut
and thenlatchPin -> HIGH
, which would be the inverse of its code. However, without the diagram, it is difficult to say.– Bacco