lbenson
Senior Member
I found this i2c mcp23017 i/o expander module on ebay:
https://www.ebay.com/itm/MCP23017-I2C-interface-16bit-I-O-Extension-Module-Pin-Board-IIC-to-GIPO-Convert/183487288052
Here it is in action with an 08M2: MCP23017 i2c module
Here's the code:
https://www.ebay.com/itm/MCP23017-I2C-interface-16bit-I-O-Extension-Module-Pin-Board-IIC-to-GIPO-Convert/183487288052
Here it is in action with an 08M2: MCP23017 i2c module
Here's the code:
Code:
'08mcp01723.bas
#picaxe 08M2
SYMBOL mcp23017 = %01000000 ; $0100 A2, A1, A0, R/W all connected to 0V
SYMBOL IODIRA = $00 ; Port A IO Direction register DEFAULT = I/P
SYMBOL IODIRB = $01 ; Port B IO Direction register DEFAULT = I/P
SYMBOL IOCON = $0A ; IO Expander config register - address $0B accesses the same register
SYMBOL GPIOA = $12 ; Port A General purpose register
SYMBOL GPIOB = $13 ; Port B General Purpose register
SYMBOL OLATA = $14 ; Port A latch register
SYMBOL OLATB = $15 ; Port B latch register
' HI2CSETUP i2cmaster, mcp23017, i2cFAST_8, i2cbyte
pause 1000
sertxd(cr,lf,"08Test5: mcp23017",13,10)
pause 1000
' HI2CSETUP i2cmaster, mcp23017, i2cFAST_16, i2cbyte
HI2CSETUP i2cmaster, mcp23017, i2cSLOW_4, i2cbyte
PAUSE 400
HI2COUT IODIRA, ($00) ;set all port A pins as outputs (0)
HI2COUT IODIRB, ($00) ;set all port B pins as outputs (0)
' HI2COUT IODIRB, ($FF) ;set all port B pins as inputs (1)
PAUSE 100
do
sertxd("_")
HI2COUT OLATA, (%11111111) ; all ON
HI2COUT OLATB, (%11111111) ; all ON
PAUSE 1000
HI2COUT OLATA, (%00000000) ; all OFF
HI2COUT OLATB, (%00000000) ; all OFF
PAUSE 1000
sertxd("-")
HI2COUT OLATA, (%10101010) ;
HI2COUT OLATB, (%01010101) ;
PAUSE 1000
HI2COUT OLATA, (%01010101) ;
HI2COUT OLATB, (%10101010) ;
PAUSE 1000
loop