hgfischer / explorer-hat

Python library for Explorer HAT

Home Page:https://shop.pimoroni.com/products/explorer-hat

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Explorer HAT/pHAT

The Explorer HAT and Explorer HAT Pro have a heap of useful input and output options that will take your Raspberry Pi projects to the next level. Great for driving motors, using analog sensors, interfacing with 5V systems, and touch (even fruit based!) interfaces.

Learn more: https://shop.pimoroni.com/products/explorer-hat

Installing The Library

Full install ( recommended ):

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:

Finding the terminal

In the new terminal window type:

curl -sS https://get.pimoroni.com/explorerhat | bash

All the pre-requisites, libraries and examples you'll need to get started will be installed for you.

If you choose to download examples you'll find them in /home/pi/Pimoroni/explorerhat/.

Library install for Python 3:

on Raspbian:

sudo apt-get install python3-explorerhat

other environments:

sudo pip3 install explorerhat

Library install for Python 2:

on Raspbian:

sudo apt-get install python-explorerhat

other environments:

sudo pip2 install explorerhat

In all cases you will have to enable the i2c bus.

Getting Started

To get started, start up a Python 3 interactive shell:

sudo python3

or

sudo idle3 &

or Python 2:

sudo python

or

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.light

To 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.motor

The Explorer pHAT has most of those features except the light and touch classes, so:

import explorerhat
explorerhat.input
explorerhat.output
explorerhat.analog
explorerhat.motor

Notes

Explorer 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!

Documentation

GPIO Pinouts

About

Python library for Explorer HAT

https://shop.pimoroni.com/products/explorer-hat


Languages

Language:Python 84.9%Language:Shell 14.4%Language:Makefile 0.7%