View Categories

Buzzer Dengan Raspberry Pi Pico

Persiapan Bahan #

– Raspberry Pi Pico / Pico W
– Buzzer
– Breadboard
– Push Button
– Kabel Jumper Male to Male
– Kabel Micro USD
– Aplikasi Thonny IDE

Wiring Buzzer Dan Push Button Ke Raspberry Pi Pico #

– connect the longer end (+) of the buzzer to GP11 (=GPIO 11)
– connect the shorter end (-) of the buzzer to a GND (ground) pin
– connect one end of the push-button to GP3 (=GPIO 3)
– connect the other end of the push-button to a GND (ground) pin

Sample Code #

from machine import Pin
import time
 
button = Pin(3, Pin.IN, Pin.PULL_UP)
buzzer = Pin(11, Pin.OUT)
 
while True:
    if button.value() == 0:
        print("button pressed")
        buzzer.value(1)
        time.sleep(1)
    else:
        buzzer.value(0)

Hasil #

What are you looking for in Partdo?