- Sun Nov 16, 2014 6:28 am
#2716
gerardwr wrote:I still have some questions on the API that are not clear to me reading the excellent documentation.
1. the node.key() function. This seems to be a way to act upon closing a switch connected to a GPIO. Is that a correct assumption? What’s the GPIO# where the switch should be connected.
2. the node.led() function. This seems to be a way to switch a LED connected connected to a GPIO. Is that a correct assumption. What’s the GPIO# where the LED should be connected.
3. Getting input from the in Lua is normally done with io.read(), but that’s not part if this implementation. What’s the way getting input into a variable?
1,2, node.key() node.led() is two api for GPIO16. in the development kit GPIO16 connect to one LED, and one BUTTON.
node.key("long", function() end ) register a call back function to LONG press(>4 or 5 seconds) of the BUTTON.
node.key("short", function() end ) register a call back function to SHORT press of the BUTTON.
node.led(400,500) means get the LED switch 400ms low and 500ms high.
some ESP module connect GPIO16 to chip RESET pin, and can't used as KEY or LED output.
3, there is no method to get user input from serial to a variable now. it go directly to lua interpreter, sorry for that.