Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Micropython ESP8266 74HC595 SPI Test
- # In this setup, I will control SIPO module 74HC595 using SPI of Lolin/NodeMCU module ESP8266
- # I will send data 00h, then check the Q0 pin value (variable: s00), must return 0
- # I will send data 01h, then check the Q0 pin value (variable: s00), must return 1
- # I will send data FFh, then check the Q0 pin value (variable: s00), must return 1
- # You can check other pins (Q1..Q7) using voltmeter if you want
- # Pinout:
- # Q1<=>
- # Q2<=>
- # Q3<=>
- # Q4<=>
- # Q5<=>
- # Q6<=>
- # Q7<=>
- # GND<=>GND
- # Q7'<=>
- # ~MR<=>3V3
- # SH<=>D5/14/SCK
- # ST<=>D2/2
- # ~OE<=>GND
- # DS<=>D7/13/MOSI
- # Q0<=>D4/2
- # VCC<=>3V3
- from machine import Pin,SoftSPI
- spi=SoftSPI(baudrate=100000,sck=Pin(14),mosi=Pin(13),miso=Pin(12))
- sst=Pin(4,Pin.OUT,value=0)
- s00=Pin(2,Pin.IN)
- sst.off()
- spi.write(b'\x00')
- sst.on()
- print('00',s00.value())
- sst.off()
- spi.write(b'\x01')
- sst.on()
- print('01',s00.value())
- sst.off()
- spi.write(b'\xFF')
- sst.on()
- print('FF',s00.value())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement