add example: reading a GPIO input with the ULP coprocessor#73
add example: reading a GPIO input with the ULP coprocessor#73ThomasWaldmann merged 1 commit intomicropython:masterfrom
Conversation
ThomasWaldmann
left a comment
There was a problem hiding this comment.
did you try the code?
a1241c9 to
d53326d
Compare
Yes. I did. Tried it on a Lolin32 clone, with GPIO4 either connected to VCC or open, and the output of the python while loop printing 1 while connected to VCC and 0 otherwise. I have a more elaborate version of that code running "in production" in a rain-gauge I built (using this board), but this example simplifies it down to the bare essentials for reading the GPIO. I have also asked @kjm1102 to try this example, as we together worked through various details to get it all to work on his ESP32 at all (long discussion in issue #70). The example is the result of that discussion, with the hope of saving the next person the time to figure it out, or having to read through #70 :). I'll add a comment to this PR, once @kjm1102 has tested this example on his ESP32. |
|
Thank you! |
This PR adds a simple example for reading a GPIO pin with the ULP coprocessor.
When running this, the ULP will read the current GPIO value (0 for off, 1 for on) into a memory location, and a loop at the end of the example will continuously print the value in that memory location. This allows seeing the value update as one toggles the input to the GPIO pin between HIGH to LOW (e.g. by connecting and disconnecting a wire from VCC (3V3) to GPIO4).