This file contains hidden or 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
pin=2 | |
local function i2cInit() | |
-- init MCP23008 GPIO expander for led & pushbutton control | |
i2c.setup(0,4,3,i2c.SLOW) --i2c init | |
i2cWrite(0x00,0xe0) --0x00 IODIR, 0xf8 = 1110 0000 sets GPIO inputs and outputs | |
i2cWrite(0x06,0xe0) --0x06 GPPU, 0xf8 = 1110 0000 sets GPIO pull up resistors | |
i2cWrite(0x09,0xe0) --0x09 GPIO, 0xf8 = 1110 0000 inputs pins high, outputs pins low | |
i2cWrite(0x02,0xe0) --0x02 GPINTEN, 0xe0 = 1110 0000 1=pin enable for interrupts | |
i2cWrite(0x03,0xe0) --0x03 DEFVAL, 0xf8 = 1110 0000 values with no buttons pushed |