Skip to content

MicroPython: LED

Leo Vidarte edited this page Mar 14, 2017 · 9 revisions

Code

from machine import Pin
from time import sleep

# GPIO16 (D0) is the internal LED for NodeMCU
led = Pin(16, Pin.OUT)

# The internal LED turn on when the pin is LOW
while True:
    led.high()
    sleep(1)
    led.low()
    sleep(1)

Here is the reason why the built in led turn on when Pin 16 is Low :)

Toggle a LED

def led_toggle():
    led.value(not led.value())
Clone this wiki locally