So i am currently interfacing sound sensor with stm32f407 disc board. i am printing Sound detected on LCD when ADC value reach user defined threshold.
Below is my code:
#Water Sensor Interfacing
#Program to detect water
from pyb import ADC, LED, Pin, delay
import uasyncio as asyncio
import utime as time
from alcd import LCD, PINLIST
sig = pyb.Pin('PC3',Pin.IN,Pin.PULL_DOWN) #sensor pin init
adc = ADC(sig)
led = pyb.LED(1) #LED Initalising
lcd = LCD(PINLIST, cols = 16) #Initalising LCD
async def sound_sensor():
ADC = adc.read()
while ADC > 200:
lcd = "Sound Detected"
# lcd = " "
loop = asyncio.get_event_loop()
In the while loop, the Sound Detected is not getting printed on LCD, but detected gets printed on terminal. If i interchange, while with if condition, its displaying the O/P on lCD.
So anyone know why while loop doesnt print data on LCD ? Or can anyone correct my code.