About ESP32 pin setting

Hi all,
the ESP32 mostly need set: pinMode(pinA, INPUT); / pinMode(pinB, INPUT); , my question is if I don't set this way for some pins like pinC or pinD, do them certainly not work? or maybe work some time?
anyway to not let them work for the pins without set?

or is it ok to rename the button in later section of the code? say first named pinA= 2; later on rename: pinC = 2, physically , there is just one button on pin2.

Thanks
Adam

Typically, pins are INPUT by default so any pin which you did not define should be in the default INPUT mode.
The chip doesn't care what variables point to which pins so it is ok to say pinA=2, pinB=2, or whatever. Also, you may start off with pinMode(2,INPUT) and change it to pinMode(2,OUTPUT) later.
It is not possible to have pins "not work". Typically pins that are to remain dormant are simply set to INPUT, thus the default.

1 Like

Have a look at the pin ‘schematic’ in the datasheet.

1 Like

i've found some of the esp32 pins confusing

see ESP32 Pinout Reference: Which GPIO pins should you use?, which provides some clues

1 Like

Thanks for help.
the question came from a multi loop sketch and few of them used 'left=0/right=14' buttons.
I used the way of:

int loopA(void)
{
  Serial.println(__func__);
  delay(1000);
  return LoopB;
}
int loopB(void)
{
  Serial.println(__func__);
  delay(1000);
  return LoopC;
}

got from another post.

got the result of multi or wrong reactions when clicked say 'left', for example,

if the 'left==1' , tft.print "abcd" on screen in LoopA and "1234" in LoopB.
there will appear "abcd" when in LoopB, and "1234" when in LoopA.

what can be the reason?

Meaningless snippet.

1 Like

need to post the entire code? what does left == 1 mean?

1 Like

Than'ks.
left==1' means left button pressed.
I'll try to recombine the code.... and post later.

Thank you JaBa.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.