Skip to content

Instantly share code, notes, and snippets.

@lucsmall
Created September 28, 2015 07:02
Show Gist options
  • Select an option

  • Save lucsmall/66d9b6539df7a0daa569 to your computer and use it in GitHub Desktop.

Select an option

Save lucsmall/66d9b6539df7a0daa569 to your computer and use it in GitHub Desktop.
Using Nodemcu to drive a 74HC595 shift register
latch_pin = 2
gpio.mode(latch_pin, gpio.OUTPUT)
gpio.write(latch_pin, gpio.LOW)
result = spi.setup(1, spi.MASTER, spi.CPOL_HIGH, spi.CPHA_LOW, spi.DATABITS_8, 0)
print(result)
while true do
for i=1,255,1 do
print(i)
spi.send(1, i)
gpio.write(latch_pin, gpio.HIGH)
gpio.write(latch_pin, gpio.LOW)
tmr.wdclr();
tmr.delay(100000);
tmr.wdclr();
end
end
@lucsmall
Copy link
Copy Markdown
Author

Connect Nodemcu D7 to 74HC595 Data (pin 14)
Connect Nodemcu D5 to 74HC595 Clock (pin 11)
Connect Nodemcu D2 to 74HC595 Latch (pin 12)

@mai109
Copy link
Copy Markdown

mai109 commented Mar 9, 2017

Super useful! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment