Blink does not work under PIO (vscode)

Hi,

I am using an ESP-01 wifi module with a USB serial programmer. The blink example does NOT work under vscode. I can compile and upload it without an error, but it does nothing. If I hover over the LED_BUILTIN, OUTPUT, HIGH or LOW words then I see them properly defined (eg: LED_BUILTIN = 1)

It can not be the USB serial programmer (or at least not directly), because the same code works perfectly under the standard arduino IDE.

Any ideas?
thanks!

#include <arduino.h>

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}

try
>#include <Arduino.h>

Does not change anything (visibly). The code still can be compiled and uploaded but the LED does not blink.

I have tested the same code with an Arduino UNO just to make sure that it is not the serial programmer of the ESP-01 causing the problem. No it’s not!

The blink code doesn’t work with an Arduino UNO either!

Also checked under Atom, same results, as expected. Just for clarification: I can upload working codes to my ESP-01 using PIO, but it seems this very basic one doesn’t work. Also struggling with the serial monitor, but I’d like this to be resolved first.

Are you sure you have the correct board selected in your platform.ini? I was having a similar issue with mbed and an STM ST32 board. I was trying to blink the LED1 user LED. It turned out that the problem was that in my platform.ini, I specified disco_f746 (STM DISCOVERY board with an F746), but I was using a nucleo board instead of a discovery board, so all of the standard macros (including LED1) were wrong.

I have selected the right board (ESP-01) when I created the project. My platformio.ini file looks like this:

[env:esp01]
platform = espressif8266
board = esp01
framework = arduino

I guess this should be correct, because I am able to use PIO to upload other stuff to my ESP-01 (eg: controlling an OLED, connecting to wifi, reading html headers etc). The LED_BUILTIN is defined as 1 which is correct for my module.

Does Blink work with Arduino IDE?

See the original problem description…

It can not be the USB serial programmer (or at least not directly), because the same code works perfectly under the standard arduino IDE.

And moreover as later found:

The blink code doesn’t work with an Arduino UNO either!

my guess is that “LED_BUILTIN” is defined for another board that has the LED connected to a different pin

(sigh)… just 3 comments above I already said:

The LED_BUILTIN is defined as 1 which is correct for my module.

it doesn’t matter if I use LED_BUILTIN or if I use 1, the LED does not blink under vscode/atom. Also no matter which one I use the LED blinks under the standard arduino IDE and under sublime.

I know this is and old post, but I face the same issue today and took me a couple of hours to found the solution:

Add this to you platformio.ini

board_build.flash_mode = dout