MicroPython: GPIO Pins - lvidarte/esp8266 GitHub Wiki

The way to connect your board to the external world, and control other components, is through the GPIO pins. Not all pins are available to use, in most cases only pins 0, 2, 4, 5, 12, 13, 14, 15, and 16 can be used.

https://raw.githubusercontent.com/lvidarte/esp8266/master/nodemcu_pins.png

The pins are available in the machine module, so make sure you import that first. Then you can create a pin using:

>>> from machine import Pin
>>> pin = Pin(14, Pin.OUT)

You can read the value on the pin using:

>>> pin.value()
0

Then set its value using:

>>> pin.value(0)
>>> pin.value(1)

Or:

>>> pin.low()
>>> pin.high()