For mcp23008:
p=232; z=/sys/class/gpio; echo $p > ${z}/export; echo out > "${z}/gpio${p}/direction"; echo 1 > "${z}/gpio${p}/value"; sleep 1; echo 0 > "${z}/gpio${p}/value"; echo $p > "${z}/unexport"
# find out which i2c address the device listens to: i2cdetect -y 0 # you should find 0x20 # Set all bits from port a to output: i2cset -y 0 0x20 0x00 0x00 # Write value to register GPIOA (0x09) oder OLATA (0x0A) # For example: for bit 0, write: i2cset -y 0 0x20 0x14 0x01
# find out which i2c address the device listens to: i2cdetect -y 0 # you should find 0x20 # Set all bits from port a to output: i2cset -y 0 0x20 0x00 0x00 # Write value to register GPIOA (0x12) oder OLATA (0x14) # For example: for bit 0, write: i2cset -y 0 0x20 0x14 0x01
Color table:
Bit | mcp23008 | mcp23017 |
---|---|---|
1 | L_GRN | L-BLU |
2 | L_BLU | L-GRN |
4 | L_RED | L-RED |
8 | R_BLU | R-BLU |
16 | R_GRN | L-GRN |
32 | R_RED | L-RED |
64 | WHITE | WHITE |
128 | HEATR | HEATR |
# Detection for mcp23017: i2cset -y 0 0x20 0x00 0x00 i2cset -y 0 0x20 0x14 0x01 i2cget -y 0 0x20 0x14 # should give 0x01 on mcp23017 and 0x00 on mcp23008