ESP8266/Py
Jump to navigation
Jump to search
microPython on ESP8266
>>> import machine >>> led = machine.Pin(2, machine.Pin.OUT) >>> led.high() >>> led.low() >>> from time import sleep >>> def blink(): ... led.low() ... sleep(0.5) ... led.high() ... >>> blink() >>> def wink(): ... led.low() ... sleep(0.1) ... led.high() ... sleep(0.2) ... led.low() ... sleep(0.1) ... led.high() ... >>> wink()
>>> d0 = machine.Pin(4, machine.Pin.IN, machine.Pin.PULL_UP) >>> d1 = machine.Pin(5, machine.Pin.IN, machine.Pin.PULL_UP) >>> d0.value() >>> >>> def callback(p): ... print(p, p.value()) ... >>> from machine import Pin >>> d0.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=callback) >>> d1.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=callback)
<IRQ>