int latchPin = 11;
int clockPin = 9;
int dataPin = 12;
byte leds = 0;
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop() {
leds = 0; // Asigură-te că toate LED-urile sunt stinse la început
updateShiftRegister();
delay(500);
// Aprinde LED-urile pe rând
for (int i = 0; i < 8; i++) {
bitSet(leds, i); // Aprinde LED-ul corespunzător bitului i
updateShiftRegister();
delay(500);
}
// Stinge LED-urile pe rând
for (int i = 0; i < 8; i++) {
bitClear(leds, i); // Stinge LED-ul corespunzător bitului i
updateShiftRegister();
delay(500);
}
}
void updateShiftRegister() {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}