int tDelay = 500; int tDelay = 500; int latchPin = 11; int clockPin = 9; int dataPin = 12; byte leds = 0; void updateShiftRegister() { digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, LSBFIRST, leds); digitalWrite(latchPin, HIGH); } void updateShiftRegister2() { digitalWrite(latchPin, HIGH); shiftOut(dataPin, clockPin, LSBFIRST, leds); digitalWrite(latchPin, LOW); } void setup() { pinMode(latchPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(clockPin, OUTPUT); Serial.begin(9600); }
void loop()
{
leds = 0;
updateShiftRegister();
for (int i = 0; i < 8; i++)
{
delay(tDelay);
bitSet(leds, i);
updateShiftRegister();
}
for (int i = 0; i < 8; i++)
{
bitClear(leds, i);
updateShiftRegister2();
delay(tDelay);
}
}
Do'stlaringiz bilan baham: |