Are pullups enabled on the RP2040?

Issue #285 resolved
Simon Walters created an issue

Someone asked me via twitter DM but my Pico broke during testing so I couldn’t answer them :(

Comments (12)

  1. John Maloney repo owner

    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.

  2. Hans Braakmann

    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).

  3. John Maloney repo owner

    You can click on the right arrow icon on the read digital pin block and turn on the pullup, like this:

    scriptImage6793776.png

    Note that you can also express this more compactly using the when <boolean> hat block:

    scriptImage6889516.png

    like this:

    scriptImage6949997.png

    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.

  4. John Maloney 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:

    scriptImage8084006.png

    scriptImage8091032.png

    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.

  5. Hans Braakmann

    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.

  6. Hans Braakmann

    As suggested I did try the IR Remote library with a VS18338B IR receiver…works like a charm👌

  7. John Maloney 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.

  8. Hans Braakmann

    John, in Python this taken me hours of fiddling to get the IR receiver on the Pico to work. Thanks again.

  9. Log in to comment