Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. # LCD en I2C-2
  2. # Boton en D4
  3. # Sensor de temp en A0
  4.  
  5. from grove_rgb_lcd import *
  6. from grovepi import *
  7. import time
  8. import grovepi
  9.  
  10. button = 4 #Port for Button
  11. status1 = 0
  12. status2 = 0
  13. sensor = 0
  14. texto = 0
  15.  
  16. pinMode(button,"INPUT")
  17.  
  18. while True:
  19. try:
  20. button_status= digitalRead(button)
  21. if button_status: #If the Button is in HIGH position, run the program
  22. if status1 == 0:
  23. setRGB(0,255,0)
  24. status2 = 0
  25. temp = grovepi.temp(sensor,'1.1')
  26. temp = round(temp, 2)
  27. tempstr = str(temp)
  28. texto = "Temp " + tempstr + "C"
  29. print(type(texto))
  30. setText(texto)
  31. print(temp)
  32. time.sleep(.5)
  33. status1 = 1
  34. else:
  35. if status2 == 0:
  36. setText(" Presiona el boton ")
  37. setRGB(255,0,0)
  38. status1 = 0
  39. status2 = 1
  40.  
  41. except KeyboardInterrupt:
  42. print("KeyboardInterrupt")
  43. break
  44.  
  45. except (IOError,TypeError) as e:
  46. print("Error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement