Skip to content

Instantly share code, notes, and snippets.

@soup-bowl
Created December 1, 2023 12:47
Show Gist options
  • Save soup-bowl/f676fa8bafed0a9d254abcae67e9e765 to your computer and use it in GitHub Desktop.
Save soup-bowl/f676fa8bafed0a9d254abcae67e9e765 to your computer and use it in GitHub Desktop.
KY-038 sensor using MicroPython - https://techatronic.com/sound-sensor-pi-pico/
from machine import Pin
from time import sleep
vu=Pin(15,Pin.OUT)
di=Pin(16,Pin.IN)
while True:
try:
if di.value()== True:
vu.value(True)
sleep(0.5)
else:
vu.value(False)
except KeyboardInterrupt:
break
@soup-bowl
Copy link
Author

soup-bowl commented Dec 1, 2023

if you buy one of these, you don't need the LED unless you're testing outputs like I am here. You could literally just provide PWR and GND to the chip, and LED2 on the board indicates whether sound is currently being detected on the potentiometer setting (LED1 is just PWR indicator).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment