This library is based on the Pibrella framework, you might find much of it familiar. It's got added motors, capacitive touch and analog input though!
Just run our installer. To do this fire up Terminal which you'll find in Menu -> Accessories -> Terminal on your Raspberry Pi desktop like so:
In the new terminal window type:
curl get.pimoroni.com/explorerhat | bashAll the pre-requisites, libraries and examples you'll need to get started will be installed for you.
Once it's finished, you should find the libraries in /home/pi/Pimoroni/explorerhat, for example (and still in the terminal) type:
cd ~/Pimoroni/explorerhat
sudo ./test.pyExplorer HAT, Explorer HAT Pro and Explorer pHAT all require i2c, the easiest way to enable it is with our simple script:
curl get.pimoroni.com/i2c | bashThey also require the SMBus Python module, which you'll need to install like so:
sudo apt-get install python-smbusAnd you'll need "pip" if you don't already have it:
sudo apt-get install python-pipYou should now be able to install Explorer HAT/pHAT with Pip.
Python 3:
sudo apt-get install python3-pip
sudo pip-3.2 install explorerhatPython 2:
sudo apt-get install python-pip
sudo pip install explorerhatTo get started, start up a Python 3 interactive shell:
sudo python3or
sudo idle3 &or Python 2:
sudo pythonor
sudo idle &...and poke Explorer HAT's innards to see what it's got to offer:
import explorerhat
explorerhat.input
explorerhat.output
explorerhat.touch
explorerhat.lightTo turn on one of the lights, address it by the name you found above:
import explorerhat
explorerhat.light.red.on()Or you can wait for a touch on one of the buttons:
import explorerhat
def ohai(channel, event):
print("Ohai! I got a touch on button: {}".format(channel))
explorerhat.touch.one.pressed(ohai)On Explorer HAT Pro, you will also find:
import explorerhat
explorerhat.analog
explorerhat.motorThe Explorer pHAT has most of those features except the light and touch classes, so:
import explorerhat
explorerhat.input
explorerhat.output
explorerhat.analog
explorerhat.motorExplorer HAT/pHAT uses an output driver chip called the ULN2003A, which contains a set of transistor pairs called a Darlington Array. It transforms the small logic signal of the Pi into something capable of driving much bigger loads, such as motors, steppers, lights and more.
The 4 outputs on Explorer can sink 5V, but not source. This means you need to connect your load to one of the 5V pins, and then to the output. When you turn the output on it will connect your circuit to ground, allowing current to flow and your load to turn on. This is the opposite of using a bare Pi GPIO pin, where you might connect to the pin and then to ground; keep this in mind!

