EIGHT LED WITH 74HC595 AND ARDUINO
ARDUINO JANUARY 4, 2017 In this lesson, you will learn how to use eight large red LEDs with an Arduino without needing to give up 8 output pins! Arduino Code int latchPin = 5; int clockPin = 6; int dataPin = 4; byte leds = 0; void setup() { pinMode(latchPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(clockPin, OUTPUT); } void loop() { leds = 0; updateShiftRegister(); delay(100); for (int i = 0; i < 8; i++) { bitSet(leds, i); updateShiftRegister(); delay(100); } leds = 0; updateShiftRegister(); delay(100); for (int i = 7; i >= 0; i–) { bitSet(leds, i); updateShiftRegister(); delay(100); } } void updateShiftRegister() { digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, LSBFIRST, leds); digitalWrite(latchPin, HIGH); } 74HC595 ARDUINO