1. Install the Python Libraries
You'll need an internet connection on your Pi
From LXTerminal (or the command line).
Let's make sure Raspbian is up to date. Type:
sudo apt-get update
Then:
sudo apt-get upgrade
Once these are finished you can type:
sudo apt-get install python-pip
sudo pip install pibrella
2. Write some code
Start the interactive Python shell by typing this into LXTerminal:
sudo python -i
Type in this code:
import pibrella
pibrella.buzzer.fail()
pibrella.light.pulse(0.2)
3. When you're done, type:
quit()
4. Write some interesting code
Start the interactive Python shell by typing this into LXTerminal:
sudo python -i
Type in this code or go to http://pibrella.com in Midori and copy and paste the code on your Pi.
# burglar alarm! (catches grinches and gruffalos)
import pibrella, signal
def alarm(pin):
pibrella.buzzer.fail() # make some noise
pibrella.light.pulse() # flash lights
def reset(pin):
pibrella.light.stop() # reset alarm
pibrella.input.a.changed(alarm) # listen for intruder
pibrella.button.pressed(reset) # in case of stupid cat
signal.pause() # waiting for intruder!
Press enter to finish the line and the code will run!
5. Now activate Input A!
Connect the 2 pins of input A with a wire or resistor.
(Press the big red button to reset)