Last active
January 9, 2023 23:35
-
-
Save 42Bots/54711c9536ef69afad7f3b9aacebb942 to your computer and use it in GitHub Desktop.
ESP8266 with a shift register 74HC595 programmed with the Arduino IDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Example of using ES8266 with a 74HC595 shift register | |
** the ShiftOut function without any libraries | |
** LEDs will count from 0 to 255 in binary | |
** For more details, see http://42bots.com | |
-------------------------------------------------------- | |
** Connections: | |
** ESP8266 GPIO13 to 74HC595 pin 14 | |
** ESP8266 GPIO15 to 74HC595 pin 12 | |
** ESP8266 GPIO14 to 74HC595 pin 11 | |
** 74HC595 Vcc is connected to 3.3V | |
** 8 LEDs connected to the 8 outputs of the 74HC595 | |
** via approariate velue resistor (I use 1k Ohm) | |
*/ | |
int latchPin = 15; // pin D8 on NodeMCU boards | |
int clockPin = 14; // pin D5 on NodeMCU boards | |
int dataPin = 13; // pin D7 on NodeMCU boards | |
void setup() | |
{ | |
//set pins to output so you can control the shift register | |
pinMode(latchPin, OUTPUT); | |
pinMode(clockPin, OUTPUT); | |
pinMode(dataPin, OUTPUT); | |
} | |
void loop() | |
{ | |
for (int i=0; i<=255; i++) { | |
digitalWrite(latchPin, LOW); | |
// shift out the bits: | |
shiftOut(dataPin, clockPin, MSBFIRST, i); | |
//take the latch pin high so the LEDs will light up: | |
digitalWrite(latchPin, HIGH); | |
// pause before next value: | |
delay(500); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment