NodeMCU GPIO与ESP8266的映照

GPIONEW TABLE 

 

new_gpio_map


** D0(GPIO16) can only be used asgpio read/write. no interrupt supported. no pwm/i2c/ow supported. *



NodeMCU的API

https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en


GPIO module

CONSTANT

gpio.OUTPUT, gpio.INPUT, gpio.INT, gpio.HIGH, gpio.LOW

gpio.mode()

Description

initialize pin to GPIO mode, set the pin in/out mode, internalpullup.

Syntax

gpio.mode(pin, mode, pullup)

Parameters

pin: 0~12, IO index
mode: gpio.OUTPUT or gpio.INPUT, orgpio.INT(interrupt mode) pullup: gpio.PULLUP or gpio.FLOAT, default:gpio.FLOAT.

Returns

nil

Example

-- set gpio 0 as output. gpio.mode(0, gpio.OUTPUT)

See also

- gpio.read()

- Backto Index

gpio.read()

Description

read pin value.

Syntax

gpio.read(pin)

Parameters

pin: 0~12, IO index

Returns

number:0 - low, 1 - high

Example

-- read value of gpio 0. gpio.read(0)

See also

- gpio.mode()


gpio.write()

Description

set pin value.

Syntax

gpio.write(pin)

Parameters

pin: 0~12, IO index
level: gpio.HIGH or gpio.LOW

Returns

nil

Example

-- set pin index 1 to GPIO mode, and set the pin to high. pin=1 gpio.mode(pin, gpio.OUTPUT) gpio.write(pin, gpio.HIGH)

See also

- gpio.mode()
-gpio.read()


gpio.trig()

Description

set the interrupt callback function for pin.

Syntax

gpio.trig(pin, type, function(level))

Parameters

pin: 1~12, IO index, pin D0 does not supportInterrupt.
type: "up", "down", "both","low", "high", which represent rising edge,falling edge, both edge, low level, high level trig modeseparately.
function(level): callback function when triggered. Thegpio level is the param. Use previous callback function if undefinedhere.

Returns

nil

Example

-- use pin 0 as the input pulse width counter pulse1 = 0 du = 0 gpio.mode(1,gpio.INT) function pin1cb(level) du = tmr.now()

NodeMCU GPIO与ESP8266的映照

上一篇:rabbitmq 开启ssl


下一篇:【Vegas原创】Docker安装Nginx,并配置端口转发