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
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
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
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