I am writing code for an LCD screen using Python
and I want it to display a flashing 'Press SELECT' message until a button on the LCD is pressed.
The problem is that while the program is in sleep, it does not register the user pressing the button, meaning that I have to press the button exactly when the message is being printed.
How can I do this without using sleep?
This is the code that I used:
#lcd.is_pressed(LCD.SELECT) - checks if button is pressed
#lcd.message - prints text on LCD
#lcd.clear - removes all text from LCD
while not lcd.is_pressed(LCD.SELECT):
lcd.message ('Press Select')
sleep(2)
lcd.clear()
sleep(2)