TouchPad Error while reading pin 2 of esp32

432 views Asked by At

I have installed micropython on ESP32 controller. I read pin 2 using below code

from machine import TouchPad, Pin
from time import sleep

def observe_pin(pin_id, d=100):
    i = 0
    t = TouchPad(Pin(pin_id))
    while i < d:
        print("{0} -> {1}".format(pin_id,t.read()))
        sleep(0.5)
        i = i + 1

If I read pin 4, it works fine.

observe_pin(4)

But If I try to read pin 2,

observe_pin(2)

it gives below error

ValueError: Touch pad error
1

There are 1 answers

3
YigalB On

This is the on board led as well. Perhaps you are using it somewhere else? Or perhaps pin 2 was not defined as input - share the whole code.