how to get mcp23017 input in binary shell
# assuming chip is addressed to 0x20
# to setup
sudo i2cset -y 1 0x20 0x00 0x00
# replace 1 with zero on rev1 pi
# iodira is 0x00 and iodirb is 0x01
# setting all pins on gpa to input
# echo as binary address GPIOA is 0x12 and GPIOB is 0x13
echo "ibase=16;obase=2;$(i2cget -y 1 0x20 0x12 b | cut -c3-4)"|bc | BC_LINE_LENGTH=9999 bc | awk '{ printf "%08d\n", $0 }'
# replace 1 with zero on rev1 pi
# Registers are shown on page 16 Table 3-3 of the data sheet https://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf
Are there any code examples left?
New code examples in category Shell/Bash
-
Shell/Bash 2022-03-27 22:30:33 wise highlight ubuntu
-
Shell/Bash 2022-03-27 22:25:19 how to send a pull request in git
-
Shell/Bash 2022-03-27 21:55:06 how to open terminal in sublime text ubuntu
-
Shell/Bash 2022-03-27 21:25:19 how to switch branch
-
Shell/Bash 2022-03-27 21:20:25 python
-
Shell/Bash 2022-03-27 21:20:04 set user as admin gitlab
-
Shell/Bash 2022-03-27 21:10:09 apache2 mod_jk proxy to tomcat connector
-
Shell/Bash 2022-03-27 20:35:12 chown
-
Shell/Bash 2022-03-27 20:15:08 awk last match