In this project you can see to control led using arduino and shift register.
For this project you need :
Arduino
Shift register 74hc595
Led
to see how work :
https://www.youtube.com/watch?v=F1K3qt9nhKc
code:
int latchPin = 3;
int clockPin = 4;
int dataPin = 2;
byte leds = 0;
int currentLED = 0;
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
leds = 0;
}
void loop()
{
leds = 0;
if (currentLED == 7)
{
currentLED = 0;
}
else
{
currentLED++;
}
bitSet(leds, currentLED);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
delay(250);
}
No comments:
Post a Comment