hi @bk, when accessing a pin directly as you do with digitalWrite(), just take a look at the schematics/wiring and all will be clear to you. It is not what you feel is right but how the LED is wired.
When wiring looks like in the left picture, it works like (Espruino) documented, because the Espruino boards' LEDs are wired this way. (Pin is configured - pinMode() - as 'push/pull' - "output"; 'pull - "opendrain" - will not work).
When wiring looks like in the right picture, it works like the blue LED on the board with the ESP8266EX, since it is wired this way. Most of the time LEDs are actually wired this way, because the simplest NPN bipolar / N ...MOS... (pin) driver is implemented to work as Open Collector / Open Drain configuration. (Pin can be configured - pinMode() - either way: 'pull' - "opendrain" - or 'push/pull' - "output").
Pics are modified from pic 'borrowed' from http://sheepdogguides.com/arduino/aht0led.htm (Sorry @MaBe, no Strichzeichnungen today). Any Web search of how to drive an LED will provide you with explanation. With a resistor and LED at hand you can experience both cases yourself.
Enjoy your bright LED day...
PS: sequence of LED and Resistor do not matter.
© Espruino, powered by microcosm.
Report a problem