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 #

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare
What are you looking for in Partdo?
× How can I help you?