• Sat 2020.09.19

    Thank you for the link @bk, now we are on the same page. On a hunch, it appears the onboard LED is being used??

    While this isn't your particular board, several manufactures, including the knock-offs may have a slightly different PCB routing, there may be some insight garnered from the sister Espruino WiFi schematic from the link at:

    https://www.espruino.com/WiFi
    which leads to:
    https://github.com/espruino/EspruinoBoard/blob/master/WiFi/pdf/espruino_wifi_sch.pdf

    Note how the Red and Green LEDs for the Espruino are wired to it's pins in comparrison to how the ESP12 Blue LED is wired to Vdd. Should the board you have be wired in this fashion, the use of digitalWrite() would have to be inverted


    Also, when reading the reference: (and I had to learn this after quite some time)

    https://www.espruino.com/Reference#l__global_digitalWrite

    please note the Right Facing arrow adjacent to the heading 'digitalWrite' which when clicked, takes one to the source:

    https://github.com/espruino/Espruino/blob/master/src/jswrap_io.c#L244

    I had hoped to locate the definition for LED1, but my configured PC that had easy access isn't at my disposal, and I wasn't able to quickly locate the file, but it most likely is within:

    https://github.com/espruino/Espruino/tree/master/src

    The intent was to show how in source that snippet funtioned for the defined LEDs with official boards.

    I did however locate a tutorial that was for the Pico (~circa 2017) that demonstrates what (then) was the suggested snippet for the onboard LED, which is slightly different than using digitalWrite() with an off-board LED. Maybe that will clear up a bit of the confusion.

    http://www.espruino.com/Control+LED+with+Button


    Ref: 'it seems to be a bit weird that on . . . LED does gets turned off'

    See explanation #7 post and onboard vs off-board above

    digitalWrite() is an instruction to set the specified GPIO pin to a specific state. As the controlled device is unknwon before the code (that you will create) is written, it can't be Ass-U-Me'd that the unknown device is an LED or how it is wired. It could just as easily be a GPS module or a Temperature sensor, for instance.

About

Avatar for Robin @Robin started