Β LED WITH SWITCH INTERFACE
π‘ LED with Switch β Interface with RP2040 (Raspberry Pi Pico)
π§Ύ Overview:
A switch (push-button) can be used as a digital input to control an LED on the RP2040. When the button is pressed, the LED turns ON; when released, it turns OFF. This demonstrates basic input-output (I/O) interfacing.
βοΈ Required Components:
RP2040 board (e.g., Raspberry Pi Pico)
1 Γ LED (any color)
1 Γ 220Ξ© resistor (current limiting for LED)
1 Γ Push-button switch
1 Γ 10kΞ© resistor (pull-down for switch)
Breadboard and jumper wires
π Circuit Diagram:
Component | GPIO Pin |
---|---|
Button1 | GPIO5 |
Button2 | GPIO4 |
LED1 | GPIO2 |
LED2 | GPIO3 |
π Notes:
Pin(2, Pin.OUT)
sets GPIO2 as output (for LED).Pin(3, Pin.OUT)
sets GPIO3Β as output (for LED).Pin(4, Pin.IN, Pin.PULL_DOWN)
sets GPIO5 as input with internal pull-down.Pin(5, Pin.IN, Pin.PULL_DOWN)
sets GPIO4Β as input with internal pull-down.The LED turns ON only when button is pressed (input is HIGH).
You can change GPIO pins if needed.
β Wokwi Setup Steps:
Go to https://wokwi.com
Create a new project β Choose Raspberry Pi Pico (Python)
Add LED and push-button components
Connect:
GPIO2 β LED1 β GND (with 220Ξ© resistor)
GPIO5 β One side of button1
GPIO3 β LED2 β GND (with 220Ξ© resistor)
GPIO4 β One side of button2
- Other side of button β GND
π§ͺ Sample Code:
π§ Key Points:
Always use a resistor with the LED to limit current.
Use a pull-down resistor (internal or external) with the button to avoid floating input.
Polarity matters: Connect the LED correctly (Anode to GPIO, Cathode to GND).
Buttons can bounce β use small delays or software debouncing if needed.
π For More Details & Project Support:
Power Integrated Solutions
Networks | Electronics | Home Automation | Water Automation | IoT | PLC | Embedded | DBMS
π Location:
10A/3, Radhakrishnan Colony,
Sasthri Road, Tennur,
Tiruchirappalli, Tamil Nadu β 620017
π View on Google Maps
π§ Email:
π± Phone / WhatsApp:
+91 76393 85448
+91 82488 85959
π Letβs Build the Future with Innovation in Education & Technology!