Are pullups enabled on the RP2040?
Someone asked me via twitter DM but my Pico broke during testing so I couldn’t answer them :(
Comments (12)
-
repo owner -
reporter Thank you-I've passed that on :)
-
Thanks Simon, I am the someone person. I get a bit confused about the Pico specs: your Pico includes an on-board programmable resistor connected to each GPIO pin. These can be set in MicroPython to pull-down resistors or pull-up resistors as required by your circuit. Works fine within Thonny…within Microblocks I can’t get it to work(without 10K resistor).
-
The Microblocks script I use
-
repo owner You can click on the right arrow icon on the read digital pin block and turn on the pullup, like this:
Note that you can also express this more compactly using the when <boolean> hat block:
like this:
The when <boolean> tests the condition 100 times per second and it won't retrigger if the script is already running. The forever loop version tests as fast as the forever loop and condition can run (usually much faster than 100 times/second), so it is better for situations that require maximum speed, such as catching incoming pulses from an IR receiver.
Often in programming, as in creative writing, there are multiple ways to express an idea. The art of coding is to find a way the both addresses the problem and is clear and easy to understand.
Actually, you also need to invert the test and make a small circuit change; see my next comment.
-
repo owner MicroBlocks supports optional pullup resistors for inputs since pullup resistors are available on all the boards we support.
When using pullup resistors with buttons, you wire the other side of the button to ground (not V+) and add a not to the test:
It has been a while since I checked, but I believe pulldown resistors are not available on all boards, which is why we decided not to support them in MicroBlocks.
-
reporter Sorry for getting my initial query wrong!
-
Thank you, your last comment with not<pullup> did the job. I also tried pulldown…in both cases that didn’t work for me. Back to Fritzing for the lessons remake.
-
As suggested I did try the IR Remote library with a VS18338B IR receiver…works like a charm
-
repo owner Glad both the button and IR remote worked for you.
FYI, there are many IR remote protocols used by different companies. MicroBlocks understands the "NEC protocol", The NEC protocol is very common, but if you find that MicroBlocks doesn't respond to a particular IR remote control it could be because that remote uses a different protocol.
-
John, in Python this taken me hours of fiddling to get the IR receiver on the Pico to work. Thanks again.
-
repo owner - changed status to resolved
- Log in to comment
In MicroBlocks, pullups on input pins are not enabled by default, but both the read digital pin and read analog pin blocks can be expanded to allow you to enable a pullup resistor.