Raspberry Pi Pico Digital input using Push button & Control Led

(Last Updated On: March 16, 2022)

Raspberry Pi Pico Digital Input:

Raspberry Pi Pico Digital input using Push button- In this article, I am going to explain how to use a Push button with the Raspberry Pi Pico. The purpose of this example is to help you understand, how to read a digital input on any GPIO pin of the Raspberry Pi Pico board. This is really an important example so make sure you don’t skip any information. If you learned how to read or detect the button click then you can read all the types of digital sensors, for example, PIR sensor, infrared obstacle sensor, Microwave Sensor, and so on. In simple words any sensor that gives you 1 or 0 as the output signal. So, in this example pushbutton is like a sensor that detects the user input.

Previous Articles:

Raspberry Pi Pico Vs Arduino.

Raspberry Pi Pico Pinout & Specs

Raspberry Pi Pico MicroPython and Thonny IDE Installation.

Raspberry Pi Pico Led examples.

Raspberry Pi Pico Oled Display Module SSD1306

Raspberry Pi Pico ADC Analog Sensor

Raspberry Pi Pico Temperature Sensor.

Raspberry Pi Pico Ultrasonic Sensor.

Raspberry Pi Pico PIR Motion Sensor.

Raspberry Pi Pico LDR Sensor, Day & Night Detection.


Amazon Links:

Raspberry Pi Pico

SSD1306 Oled Display Module

Potentiometer

PIR Sensor

5V Buzzer

Digital LDR module

12V Relay Module

HC-SR04 Ultrasonic Sensor

Push Buttons

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

So, to make it more interesting I am going to control an LED, so, each time the button is pressed the LED will change its state. Let’s go ahead and take a look at the circuit diagram.



Raspberry Pi Pico Push Button Circuit:

Raspberry Pi Pico

One side of the Push button is connected with 3.3V pin of the Raspberry Pi Pico while the other side of the push button is connected with the digital input GP14 pin of the Pico board.

The LED connection with the Pico Board remains exactly the same. Now, let’s take a look at the programming.

Raspberry Pi Pico Push Button Code:

The purpose of this program is to toggle the LED. As the LED is an output device so that’s why I set it as output “OUT” and as Push button is an input device so that’s why I set it as input “IN”. Reset of the code is pretty straightforward. If a button click is detected then simply toggle the LED means if the LED is OFF then turn it ON or if the LED is ON then turn it OFF. Now, let’s go ahead and run this code.


When Button is not pressed.

Raspberry Pi Pico

When the button is pressed.

Raspberry Pi Pico

You can see each time I press the button, the LED changes its state.

Next article, Raspberry Pi Pico SSD1306 Oled display Module interfacing, and programming.

Watch Video:

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

%d bloggers like this: