Skip to content

2. Software Installation

MODMYPI edited this page Aug 22, 2018 · 2 revisions

Software Installation

Software installation is nice and easy to, simply follow these steps and you'll be ready to start coding in no time at all!

Make sure your Pi is up-to-date

sudo apt-get update
sudo apt-get upgrade
sudo rpi-update
sudo reboot

Enable I2C

sudo raspi-config

From the menu select "5 Interfacing Options"

Then select "P5 I2C"

Select "Yes" to enable.

Install WiringPi Python

sudo apt-get install python-dev python-pip
sudo pip install wiringpi

Download Example Code

Please note: examples use WiringPi, a Python 2 specific application. Please ensure you are using Python 2, not Python 3 to run examples. Running on the incorrect version of Python will yield the following error:

ImportError: No module named 'wiringpi'

With all the software installed you are ready to go! If you need a little helping hand to get you started, you can download the sample code from the repo to get a feel of how things work. There are two example scripts "led.py" and "switch_led.py"

led.py gives you a basic example of how to use the MCP23017 pins as outputs.

switch_led.py shows you how to use them ICs as both inputs and outputs, it also makes use of both MCP23017 ICs

multi_switch_led.py is an extended example of the switch_led.py, it uses multiple inputs and outputs

git clone git://github.com/modmypi/MCP23017_HAT.git
cd MCP23017_HAT
sudo python2 led.py
or
sudo python2 switch_led.py

You can’t perform that action at this time.