Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LCD en I2C-2
- # Boton en D4
- # Sensor de temp en A0
- from grove_rgb_lcd import *
- from grovepi import *
- import time
- import grovepi
- button = 4 #Port for Button
- status1 = 0
- status2 = 0
- sensor = 0
- texto = 0
- pinMode(button,"INPUT")
- while True:
- try:
- button_status= digitalRead(button)
- if button_status: #If the Button is in HIGH position, run the program
- if status1 == 0:
- setRGB(0,255,0)
- status2 = 0
- temp = grovepi.temp(sensor,'1.1')
- temp = round(temp, 2)
- tempstr = str(temp)
- texto = "Temp " + tempstr + "C"
- print(type(texto))
- setText(texto)
- print(temp)
- time.sleep(.5)
- status1 = 1
- else:
- if status2 == 0:
- setText(" Presiona el boton ")
- setRGB(255,0,0)
- status1 = 0
- status2 = 1
- except KeyboardInterrupt:
- print("KeyboardInterrupt")
- break
- except (IOError,TypeError) as e:
- print("Error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement