Changing Pin from ADC to Digital problem

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
tahir
Posts: 2
Joined: Fri Jul 10, 2020 12:19 pm

Changing Pin from ADC to Digital problem

Post by tahir » Fri Jul 10, 2020 2:07 pm

I am trying to read the coordinates of a 4-wire analog tft touchscreen https://www.adafruit.com/product/2478 using an ESP32 WROOM 32 based development board.
In order to read touchpoint, the pins need to be changed from input to output and viceversa. However, once a pin is declared as analog, it can not be fully (re)used as a digital Pin. The set can only be set to 0 and but not to 1. The pin remains analog unless the board is reset. To use the analog pin as digital, the boards needs to be power reset(using the reset button or power off and on). machine.reset does not work.

Code: Select all

>>> from machine import Pin, ADC
>>> pin = Pin(32, Pin.OUT, value=0)
>>> pin.value()
0
>>> pin.on()
>>> pin.value()
1
>>> pin = ADC(Pin(32))
>>> pin.read()
0
>>> pin = Pin(32, Pin.OUT, value=0)
>>> pin.value()
0
>>> pin.on()
>>> pin.value()
0
>>> pin.value(1)
>>> pin.value()
0
>>> pin.on()
>>> pin.value()
0
Is there any way to overcome this?

Thanks

tahir
Posts: 2
Joined: Fri Jul 10, 2020 12:19 pm

Re: Changing Pin from ADC to Digital problem

Post by tahir » Mon Sep 07, 2020 1:57 pm

Found the same issue raised on GitHub.
https://github.com/micropython/micropython/issues/5771

Post Reply