Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By cesar182
#63794 Greetings to all ... I will be new with the ESP8266 and not too long update the firmware of the same to be able to program it with the IDE Arduino, to start I decided to make the example of blinking of the LED, making use of the pin GPIO2, the problem that I have Is that once the program has been re-started the ESP with the led connected to the output pin, but the LED only stays on all the time, and for more than restarting the ESP again and again, the led is only on. But if I take the LED off and restart the ESP and then turn on the led again, the program is working correctly, and the LED starts blinking.
Please can anyone help me with this little problem, and can you tell me what's going on? first of all, Thanks

P.S: I have connected a resistance of 330 ohms as protection to the output of the GPIO2 together with the led. And I leave the small code attached

Code: Select allvoid setup() {
  // initialize digital pin as an output.
  pinMode(2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}
User avatar
By martinayotte
#63795 There are 2 ways to connect an LED on a GPIO, in sink mode or in source mode.
For normal GPIO, both modes can be used, but you need to be aware that for sink mode, the GPIO need to be bring to LOW or zero to make the LED turned ON.
But since GPIO0 and GPIO2 needs to be HIGH at boot time to enter in execute mode, the source mode can not be used since it is acting as a pull-down, preventing ESP to go in execute mode.
So, for those 2 GPIOs, you don't have choice to connect the LED in sink mode and reverse all digitalWrite() states.
Image
User avatar
By cesar182
#63804 Thank you very much martinayotte, I did what you told me and now the ESP works well for me, although from here on I will have to take into account how to reverse the states of the outputs. Anyway, thanks for the help :D