I am doing a test. I have raspberry pi zero with a temperature sensor that gets readings every one hour. The code is inside a while loop.
So, when I do not press the button I continuously get every one hour the string "no". The issue I have is that even when I press the button I still get "no". Because, I am guessing, I need to press the button at the time that the while loop wakes up.
Code: Select all
while True: #here is the code for reading temps if button.is_pressed: data = 'yes' else: data = 'no' print(data) time.sleep(3600)
Is there a way to have a button that is constantly checking if pressed WHILST having a time.sleep(3600)?