Last active
December 9, 2017 09:44
-
-
Save paulcuth/f646f220a617a5fe43a1 to your computer and use it in GitHub Desktop.
A choice of quick cheats for those that don't have time to keep referring to the ESP8266 GPIO pin -> IO index map.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- You could setup global vars: | |
for k,v in ipairs{3,10,4,9,2,1,nil,nil,nil,11,12,nil,6,7,5,8,0} do _G['GPIO'..k-1]=v end | |
-- and use them like this: | |
gpio.mode(GPIO2, gpio.OUTPUT) | |
gpio.write(GPIO2, gpio.WRITE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Or set them up in the gpio namespace: | |
gpio=setmetatable({},{__index=gpio}) for k,v in ipairs{3,10,4,9,2,1,nil,nil,nil,11,12,nil,6,7,5,8,0} do gpio['GPIO'..k-1]=v end | |
-- and use them like this: | |
gpio.mode(gpio.GPIO2, gpio.OUTPUT) | |
gpio.write(gpio.GPIO2, gpio.WRITE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ipairs is not working for me. The loop stops at first nil value.
Changed ipairs to pairs and worked ok.