Int tDelay = 500; int latchPin = 11; int clockPin = 9; int dataPin = 12


Download 207.66 Kb.
Sana02.05.2023
Hajmi207.66 Kb.
#1421883
Bog'liq
16-17

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);
}
}
Download 207.66 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling