Hello there, I was running out of pins on my ESP32 so I was thinking to reuse the GPIO0 (aka Boot button) as a user button
but I am unable to read the state of it from my sketch
// set pin numbers
const int BootButtonPin = 0;
const int UpButtonPin = 25;
const int CenterButtonPin = 26;
const int DownButtonPin = 4;
const int TuneRotaryButtonPin = 39;
// variable for storing the pushbutton status
int BootButtonState = 0;
int UpButtonState = 0;
int CenterButtonState = 0;
int DownButtonState = 0;
int TuneRotaryButtonState = 0;
void setup() {
Serial.begin(115200);
// initialize the pushbutton pin as an input
pinMode(BootButtonPin, INPUT); //Boot button
pinMode(UpButtonPin, INPUT); //UP
pinMode(CenterButtonPin, INPUT); //CENTER
pinMode(DownButtonPin, INPUT); //DOWN
pinMode(TuneRotaryButtonPin, INPUT); //Tune rotary potentiometer push button
Serial.println("Power on");
}
void loop() {
// read the state of the pushbutton value
BootButtonState = digitalRead(BootButtonPin);;
UpButtonState = digitalRead(UpButtonPin);;
CenterButtonState = digitalRead(CenterButtonPin);;
DownButtonState = digitalRead(DownButtonPin);;
TuneRotaryButtonState = digitalRead(TuneRotaryButtonPin);;
//Serial.println("CenterButtonStat: " + CenterButtonState);
if (BootButtonState == HIGH) {
Serial.print("Boot button pressed");
Serial.println();
}
if (UpButtonState == LOW) {
Serial.print("Up button pressed");
Serial.println();
}
if (CenterButtonState == LOW) {
Serial.print("Center button pressed");
Serial.println();
}
if (DownButtonState == LOW) {
Serial.print("Down button pressed");
Serial.println();
}
if (TuneRotaryButtonState == LOW) {
Serial.print("Tune rotary button pressed");
Serial.println();
}
}
I know GPIO0 should be active high instead of low like other buttons, but nothing I tried works properly
at first when I power on my ESP32 GPIO0 will go print, but then when I press it nothing happens
Other buttons are working totaly fine, I can also enter into flash mode with GPIO0 held at startup
Its just that I am unable to read its state from my program
Can someone help?