Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Electorials Electronics
Published © GPL3+

Pi Project 005: Sound-Activated LED

A simple project involving a Sound Sensor Module that controls an LED.

BeginnerProtip-102 minutes335
Pi Project 005: Sound-Activated LED

Things used in this project

Story

Read more

Code

Raspberry Pi Sound-Activated LED Project

Python
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(4, GPIO.OUT, initial = GPIO.LOW)

while True:
    sensor = GPIO.input(3)
    if sensor == 0:
        print("No sound!")
        GPIO.output(4, 0)
    elif sensor == 1:
        print("Sound detected!")
        GPIO.output(4, 1)

Credits

Electorials Electronics
85 projects • 66 followers
I'm an electronic hobbyist interested in anything, from Arduino to drones. I plan to educate people with the content on my website.
Contact

Comments

Please log in or sign up to comment.