Raspberry Pi with the IO Expander

A month ago my Raspberry Pi arrived and since then I have been wanting to control external devices with it. Like any other newbie, I was eager to do something with it as soon as possible and spent hours and hours reading and trying out sample codes from experienced Pi users from the internet. After all the countless hours of reading forums and looking at step by step tutorials I am still not confident to directly connect LEDs and buttons to my Pi as I am afraid to fry it up to smokes.
Raspberry Pi with the IO Expander
Until I read about the MCP23017 IO Expander from Nathan Chantrell and SKPANG, which from my readings will protect my Pi and give me peace of mind while experimenting with it, so I bought one (Slice of PI/O). Unfortunately, most examples I found are for output only and not so many for input (I guess I just got lazy).  With quite a lot of trial and error, I finally figured out how to accept external input using Python with Smbus (i2c).  This is the reason why I made this blog,  I want to share what I have learned to those like me who has zero knowledge of the Linux operating system, the Python programming language and even in using the i2c to interface the Pi with other devices.  I hope this will help minimize the number of hours that will be spent looking for a basic example of programming the GPIO (input and output) of the Raspberry Pi with the MCP23017 IO expander.
– Raspberry Pi version 2
– MCP23017 IO Expander add-on
– breadboard
– 9 pcs LEDs
– 9 pcs 470ohm resistors
– 5 pcs micro switches
– 5 pcs 10Kohm resistors
– connecting wires or ribbon cable
(please see setup photo)
Raspberry Pi with the IO Expander
– Raspbian Wheezy (latest version) from raspberrypi.org
– Python-pygame (sudo apt-get install python-pygame)
– MCP23017 IO Expander driver (i2ctools, smbus and etc). (How to?)
Scroll to Top
Read previous post:
Internet of Things Toilet Uploads Events to the Cloud (Raspberry PI)

Internet of Things Toilet uploads flush events and toilet paper roll change out events to Google Drive spreadsheet. How does...