Interfacing KY038 sound sensor with Raspberry pi Pico
Micropython code
from machine import Pin#importing Pin Class from machine module.
import utime#importing time module
led=Pin(15,Pin.OUT)  #created an led object and assigning the GPIOPin 15 to as an OUTPUT
button=Pin(16,Pin.IN,Pin.PULL_DOWN) #created an object button and assigned to GPIO Pin 16 as an INPUT PULL_DOWN.
def led_toggle(irq): #created a function led_toggle.
    global led
    led.toggle()
button.irq(trigger=Pin.IRQ_RISING,handler=led_toggle)
 

Comments
Post a Comment