Error - Light Led with 74HC595

1

Hello

I'm trying to light the led 1 on 74HC595 pin and the rest gets deleted and then delete the led 1 and light only led 2 that is in pin 2 of 74HC595 , but problem I'm having is that all LEDs are lit together, what could 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

    
asked by anonymous 23.05.2016 / 02:58

1 answer

0

Try to use a delay between the high in the loop is better

#define latchPin 5
#define clockPin 6
#define dataPin 4
#define tempoAtualiza 1
void setup() {

pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}

void loop() {

digitalWrite(latchPin, HIGH);
delay(tempoAtualiza * 1000);
digitalWrite(latchPin, LOW);
delay(tempoAtualiza * 1000);

digitalWrite(latchPin, HIGH);
delay(tempoAtualiza * 1000);
digitalWrite(latchPin, LOW);
delay(tempoAtualiza * 1000);

}
    
23.05.2016 / 03:09