sohotcall

Micropython ESP8266 74HC595 SPI Test

Jan 28th, 2021
479
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Micropython ESP8266 74HC595 SPI Test
  2. # In this setup, I will control SIPO module 74HC595 using SPI of Lolin/NodeMCU module ESP8266
  3. # I will send data 00h, then check the Q0 pin value (variable: s00), must return 0
  4. # I will send data 01h, then check the Q0 pin value (variable: s00), must return 1
  5. # I will send data FFh, then check the Q0 pin value (variable: s00), must return 1
  6. # You can check other pins (Q1..Q7) using voltmeter if you want
  7. # Pinout:
  8. #  Q1<=>
  9. #  Q2<=>
  10. #  Q3<=>
  11. #  Q4<=>
  12. #  Q5<=>
  13. #  Q6<=>
  14. #  Q7<=>
  15. # GND<=>GND
  16. # Q7'<=>
  17. # ~MR<=>3V3
  18. #  SH<=>D5/14/SCK
  19. #  ST<=>D2/2
  20. # ~OE<=>GND
  21. #  DS<=>D7/13/MOSI
  22. #  Q0<=>D4/2
  23. # VCC<=>3V3
  24.  
  25. from machine import Pin,SoftSPI
  26. spi=SoftSPI(baudrate=100000,sck=Pin(14),mosi=Pin(13),miso=Pin(12))
  27. sst=Pin(4,Pin.OUT,value=0)
  28. s00=Pin(2,Pin.IN)
  29.  
  30. sst.off()
  31. spi.write(b'\x00')
  32. sst.on()
  33. print('00',s00.value())
  34.  
  35. sst.off()
  36. spi.write(b'\x01')
  37. sst.on()
  38. print('01',s00.value())
  39.  
  40. sst.off()
  41. spi.write(b'\xFF')
  42. sst.on()
  43. print('FF',s00.value())
  44.  
RAW Paste Data