http://sourceforge.net/p/raspberry-gpio-python/wiki/Inputs/ ***
http://pythonhosted.org/RPIO/rpio_py.html#gpio-input-output ***
Do recipe 12.2 and then 12.5.
Do recipe 10.13. This recipe describes an alternative to the
polling approach we have been using to detect switch presses. But
first, why do we need an alternative?
In the polling approach, we repeatedly check the state of the
input pin in a loop and when a particular state is detected (the
event) we execute some event handling code:
while True:
if GPIO.input(18) == False:
# put the event handling code here
time.sleep(0.1)
New
functions from module RPi.GPIO:
http://sourceforge.net/p/raspberry-gpio-python/wiki/Inputs/ ***
Do recipe 12.6. Test your code using program switch.py
from the textbook.
Exercise: When done, change
the circuit to a pull-down resistor and modify switch.py
appropriately to test your circuit. Important:
the circuit you want to build is the second of the above two
circuits and make sure that you use a 10kOhm and a 1kOhm circuit
as shown above. Make sure to call me to verify your circuit
before you connect the wire to the 3.3V pin.
To verify the resistance of a resistor, you will find this
online resistor color code calculator helpful:
http://en.wikipedia.org/wiki/Rotary_encoder#Incremental_rotary_encoder ***
http://en.wikipedia.org/wiki/Passive_infrared_sensor ***The program pir.py, mentioned in the book, is mission from the book's code. To get the program, do
$ wget http://reed.cs.depaul.edu/lperkovic/csc299/lab3/pir.pyIn the next two exercises, you will modify program pir.py so that, when motion is detected, a photo is taken and an email is sent to you.
This command should be typed from within the directory in which you want to download the program.$ wget http://reed.cs.depaul.edu/lperkovic/csc299/lab3/sendmail.py
Raspberry Pi Cookbook
https://docs.python.org/3/library/smtplib.htmlExercise: When done, modify program pir.py from recipe 12.9 (and rename to pir_email.py) so that a short email is sent to you every time motion is detected.
https://docs.python.org/3/library/smtplib.html#smtp-example ***
$ sudo apt-get install python3-picameraFor more info, see
$ sudo apt-get install python-picamera
http://picamera.readthedocs.org/en/release-1.12/install.html#raspbian-installation ***Download the Python program that illustrates how photos and videos are made from within Python:
http://picamera.readthedocs.org/en/release-1.12/quickstart.html ***
$ wget http://reed.cs.depaul.edu/lperkovic/csc299/lab3/test_camera.pyExercise: When done, modify program pir.py from recipe 12.9 (and rename to pir_photo.py) so that a photo is taken every time motion is detected.