Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add example: reading a GPIO input with the ULP coprocessor #73

Merged
merged 1 commit into from
May 24, 2022

Conversation

wnienhaus
Copy link
Collaborator

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

@wnienhaus wnienhaus mentioned this pull request May 22, 2022
Copy link
Collaborator

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try the code?

examples/readgpio.py Outdated Show resolved Hide resolved
examples/readgpio.py Outdated Show resolved Hide resolved
@wnienhaus
Copy link
Collaborator Author

did you try the code?

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.

@wnienhaus
Copy link
Collaborator Author

wnienhaus commented May 24, 2022

As per @kjm1102 (mentioned in issue #70):

The #73 demo program works great, displays 0x0 (gpio4 not connected to anything) or 0x1(gpio4 bridged to 3v3).

So, I guess we can merge.

@ThomasWaldmann ThomasWaldmann merged commit 7eb2a80 into micropython:master May 24, 2022
@wnienhaus
Copy link
Collaborator Author

Thank you!

@wnienhaus wnienhaus deleted the readgpio_example branch June 14, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants