I've hooked up a LCD display to a project I'm working on. I have many inputs/outputs and I want to display different messages depending on the state of the inputs. Now before I start to complicate / add more hardware. I need some assistance. When no inputs are active I want the LCD to display the message "Awaiting Input" then once input one is received I want to display "Input one active". I am currently using a while true loop but the problem occurs once I clear the LCD display as every time it loops it pulses the text on the screen. Is there a better way to do this outside of a while true loop?
Here is my current code
import I2C_LCD_driver
import time
import pigpio
mylcd = I2C_LCD_driver.lcd()
Debounce = 0.5
Input23 = 23
Input24 = 24
Input17 = 17
Output18 = 18
Output4 = 4
pi_GPIO = pigpio.pi()
pi_GPIO.set_mode(Input23, pigpio.INPUT)
pi_GPIO.set_pull_up_down(Input23 , pigpio.PUD_UP)
pi_GPIO.set_mode(Input24, pigpio.INPUT)
pi_GPIO.set_pull_up_down(Input24 , pigpio.PUD_UP)
pi_GPIO.set_mode(Input17, pigpio.INPUT)
pi_GPIO.set_pull_up_down(Input17 , pigpio.PUD_UP)
pi_GPIO.set_mode(Output18, pigpio.OUTPUT)
pi_GPIO.set_mode(Output4, pigpio.OUTPUT)
while True:
if pi_GPIO.read(Input23):
pi_GPIO.write(18, 0)
mylcd.lcd_clear()
mylcd.lcd_display_string("Input 1 Active", 1)
time.sleep(Debounce)
else:
pi_GPIO.read(Input23)
pi_GPIO.write(18, 1)
mylcd.lcd_clear()
mylcd.lcd_display_string("Awaiting Input", 1)
mylcd.lcd_display_string("Detection", 2)
time.sleep(Debounce)