What does the KEY switch do on the adapter board?
- So, let’s talk about the adapter board and its nifty KEY switch.
- This little switch is connected to GPU14, which is pretty cool.
- When you give it a press, it actually controls the LED hooked up to GPU25.
- Here’s the fun part: pressing the switch lights up the LED, and when you let go? Yep, it turns off.
- Simple as that!.
How do you configure LED and button control?
- So, let’s dive into setting up the LED and key press logic! First off, you need to fire up your previous code, wipe it clean, and import the essential Pin module from the machine library.
- Next, we’re going to pin 25 for our LED and make sure it’s set up as an output.
- Now, for the button, we’re using pin 14 and configuring it as an input with a pull-up resistor to make sure it knows when you’re pressing it.
- Here’s the cool part: when you haven’t pressed the switch, the state is high, which means the LED is off.
- But as soon as you press that button, the state drops to low, lighting up the LED.
- And don’t forget, if you leave the button pressed, the LED stays lit; once you release it, the LED turns off again..
How to Fix LED Control Code Issues?
- So, here’s the scoop: there was a little hiccup in the code where “output” got mixed up with “out,” and we had to fix that.
- Once that was sorted, we double-checked to make sure everything was working smoothly.
- Now, when we hit the key, the LED lights up, and when we let go, it turns off—pretty cool, right? This key switch setup means you can easily control the LED.
- And the best part? Hitting and releasing that key shows that the input and output are working like a charm!.
What did we learn from this project?
- So, we used MicroPython to get our LED and switch running on the Raspberry Pi Pico, which was a fantastic way to dive into the basics of GPIO manipulation.
- While we’re wrapping up this project for now, it’s exciting to think about the new topics we’ll explore next.
- It’s really all about keeping that educational journey going!.