Here is my code:
#define LED_BUILTIN 12
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
The above code works perfectly fine for GPIO_2 but fails for GPIO_12. Is it giving a fault because I am using a touchpad pin or there is some other error?
I have attached an LED to GPIO_12 of the ESP32. After uploading the program, my LED is not blinking. I have tried to connect voltmeter to GPIO_12 and it is giving 0.5 volts with minor fluctuation. I was expecting a change of voltage after each second as per HIGH/LOW conditions of my code but unfortunately, I am not getting the desired result. What could be the possible reason?
-
\$\begingroup\$ That would depend on which exact ESP32 module you have and what else is connected on that pin. \$\endgroup\$Justme– Justme2022年12月05日 13:50:30 +00:00Commented Dec 5, 2022 at 13:50
-
\$\begingroup\$ how are you connecting the LED to GPIO_12? \$\endgroup\$Paul Ghobril– Paul Ghobril2022年12月05日 14:19:11 +00:00Commented Dec 5, 2022 at 14:19
-
\$\begingroup\$ Exactly, now I have found out the solution. The code for which I was following the reference website contained 36 pins which mean 18 pins on each side but in my version of the board there were total 30 pins on my board which mean 15 pins on each side. Now that I have manual of that board, everything is fine, aligned and makes perfect sense anyways, Thanks. \$\endgroup\$Imran Mumtaz– Imran Mumtaz2022年12月05日 14:19:53 +00:00Commented Dec 5, 2022 at 14:19
-
\$\begingroup\$ @Paul Ghobril, I was connecting it through 220 ohms resistor. Anyways, that was not the issue in my case and I have got the answer and posted it below in answer section. \$\endgroup\$Imran Mumtaz– Imran Mumtaz2022年12月05日 14:25:52 +00:00Commented Dec 5, 2022 at 14:25
1 Answer 1
Now I have found out the solution so let's share so that others can also get benefit. The code for which I was following the reference website contained 36 pins which mean 18 pins on each side but in my version of the board there were total 30 pins on my board which mean 15 pins on each side. Now that I have got pin out reference of that board and my board also, everything is fine, aligned and makes perfect sense. Problem was that the hardware which the reference website referred to had different hardware version with 36 pins and my hardware contained 30 total pins and was a different version of ESP32.
-
1\$\begingroup\$ So, in short, you toggled GPIO 12 but accidentally had been measuring a wrong pin? \$\endgroup\$Justme– Justme2022年12月05日 14:39:38 +00:00Commented Dec 5, 2022 at 14:39
-
\$\begingroup\$ No, I was toggling GPIO 26 but was mistaken that I was toggling GPIO12 due to following wrong ESP32 devkit version pinout diagram. When I used the right board version pinout diagram which matched with my board hardware, everything got ok. \$\endgroup\$Imran Mumtaz– Imran Mumtaz2022年12月05日 15:22:50 +00:00Commented Dec 5, 2022 at 15:22