LED Control Dengan Push Button Di Pi Pico

Persiapan Bahan #

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

Wiring LED dan Push Button dengan Raspberry Pi Pico #

  • Connect the Push Button Pin to GP0 & its cross pin to GND.
  • Connect the LED positive Pin to Raspberry Pi Pico GP1 Pin
  • Negative Pin LED to GND Pin.

Sampling Code #

from machine import Pin
from utime import sleep_ms
button = Pin(0, Pin.IN, Pin.PULL_UP)   #Internal pull-up
led = Pin(1, Pin.OUT)
State=0                                #0 means that the light is currently off
if __name__ == '__main__':
    while True:
        if button.value() == 0:       #key press
            if State==0: 
                while button.value() == 0:
                while button.value()== 0:

Run the script and you can start checking the LED State by pressing the button.

When a button is pressed the LED will turn ON.

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
What are you looking for in Partdo?
× How can I help you?