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
import pyb
from pyb import ADC, LED, Pin, delay
import uasyncio as asyncio
import utime as time
from alcd import LCD, PINLIST
#Initalising ADC
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:
led.toggle()
print("Detected")
lcd[0] = "Sound Detected"
pyb.delay(100)
# else:
# led.off()
# lcd[0] = " "
while True:
loop = asyncio.get_event_loop()
loop.run_until_complete(sound_sensor())
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.
Thanks