-
-
Save fayvlad/99cf8091726ace71c56d9f2db12cc9cd to your computer and use it in GitHub Desktop.
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
pin=8 | |
spi.setup(1, spi.MASTER, spi.CPOL_HIGH, spi.CPHA_LOW, spi.DATABITS_8, 0); | |
gpio.mode(pin, gpio.OUTPUT) | |
--gpio.write(pin, gpio.LOW) | |
data = { | |
'00000001', | |
'00000011', | |
'00000111', | |
'00001111', | |
'00011111', | |
'00111111', | |
'01111111', | |
'11111111', | |
'11111110', | |
'11111100', | |
'11111000', | |
'11110000', | |
'11100000', | |
'11000000', | |
'10000000', | |
'00000001', | |
'00000011', | |
'00000111', | |
'00001111', | |
'00011111', | |
'00111111', | |
'01111111', | |
'11111111', | |
'11111110', | |
'11111100', | |
'11111000', | |
'11110000', | |
'11100000', | |
'11000000', | |
'10000000', | |
'10101010', | |
'01010101', | |
} | |
print(table.getn(data)) | |
function sendData(byte) | |
gpio.write(pin, gpio.LOW) | |
tmr.delay(20) | |
spi.send(1,byte) | |
gpio.write(pin, gpio.HIGH) | |
tmr.delay(1000000) | |
print(byte) | |
tmr.wdclr() | |
end | |
while 1 do | |
for j=1,table.getn(data),1 do | |
print(j .. '=' .. data[j] .. '=') | |
sendData(tonumber(data[j],2)) | |
end | |
end | |
-- https://mwhprojects.wordpress.com/category/projects-2/pcb/74hc595-shift-register-breakout/ | |
-- https://techtutorialsx.com/2016/08/30/esp8266-connection-to-sn74hc595/ | |
-- http://www.esp8266.com/viewtopic.php?f=19&t=2130# | |
-- http://www.instructables.com/id/NODEMCU-LUA-ESP8266-With-74HC595-LED-and-Matrix-Dr/ | |
-- http://www.instructables.com/id/How-Shift-Registers-Work-74HC595/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment