![]() ![]() Follow the steps in the particular order:įirstly, we will import the library for the Pin class from the machine module. We will create a script to control an LED with a push button for Raspberry Pi Pico in MicroPython. Control LED with Button MicroPython Script We will read these two states of the push button and turn on and turn off the LED accordingly. When the button is released a logic state of low (0) will be passed on GPIO13 and the push button input will be in a logic state LOW. When the push button is pressed, a logic state of high (1) will be passed on GPIO13 and the push button input will be in a high state. The other end of the resistor is connected with the common ground. One terminal is powered by 3.3 volts from Raspberry Pi Pico and the other terminal is connected by GPIO13 and the 10k ohm resistor which acts as a pull-down resistor. In the above schematic, we can see that GPIO14 is connected with the anode pin of LED, and the cathode pin is connected with the common ground through the 220-ohm resistor. Raspberry Pi Pico with LED and push button connection diagram Schematic of Raspberry Pi Pico with a Push Button and an LED ![]() If you have not followed our previous tutorial, you check here: We will be using the same Thonny IDE as we have done previously when we learned how to blink and chase LEDs in micro-python. Push Button Interfacing Raspberry Pi Pico Tutorial Prerequisitesīefore we start this lesson make sure you are familiar with and have the latest version Python 3 in your system, have set up MicoPython in Raspberry Pi Pico, and have a running Integrated Development Environment(IDE) in which we will be doing the programming. ![]() We will read the state of a push Button using the input pin of pic and turn on the Led consequently. Accordingly, we will also show how to interface a push button with Raspberry Pi Pico. Previously, we learned how to use GPIO pins for the Pi Pico board as output pins but in this tutorial, we’ll see how the same GPIO pins can also be used to acquire the digital inputs from the module. In this tutorial, we will learn how to use a push button in order to turn a led on and off with Raspberry Pi Pico using MicroPython. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |