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?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source