Skip to content

Commit

Permalink
Updated GPIO pins and description in README
Browse files Browse the repository at this point in the history
  • Loading branch information
reinzor committed Mar 21, 2018
1 parent 778e5ee commit 77a874b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Selfiebooth Baas van Horst aan de Maas

![Illustration Selfiebooth](illustration.png)
![Illustration Selfiebooth](doc/illustration.png)
Python code and assets Selfiebooth Baas van Horst aan de Maas.

## Hardware setup
Expand All @@ -9,9 +9,23 @@ Python code and assets Selfiebooth Baas van Horst aan de Maas.

Connect raspberry PI camera module to board

![Camera connection](doc/camera_connection.png)

### 2. GPIO setup for button

TODO: Add readme for GPIO setup (hardware)
We use BCM pin 3 (index 5) since it has an internal pull-up resistor. This means that the digital value will get pulled-up
to 1 if it is floating (no connection to the ground or a 3v or 5v output). Pin 3 is floating when our switch is open, so since
we have a pull-up resistor, the digital value will be 1 when the swich (push button) is open (not pressed). If the push button
is pressed, we would like the value to go from 1 to 0 and raise a falling event. Therefore, the other wire needs to be
attached to the ground (index 9). We use a pull-up vs a pull-down since it is less sensitive for interference.

Index 3 (BCM pin 3) and index 9 (ground) are illustrated in this figure:

![GPIO set-up](doc/gpio_setup.png)

Here you see a photo of the connection:

![GPIO connection](doc/gpio_connection.png)

## Software setup

Expand Down
Binary file added doc/illustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/selfiebooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import picamera
import RPi.GPIO as GPIO

BCM_PIN = 3


class Selfiebooth(picamera.PiCamera):

Expand Down Expand Up @@ -54,8 +56,8 @@ def __init__(self, config, raw_output_dir):
@staticmethod
def _setup_gpio():
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP)
GPIO.add_event_detect(17, GPIO.FALLING)
GPIO.setup(BCM_PIN, GPIO.IN)
GPIO.add_event_detect(BCM_PIN, GPIO.FALLING)

def _setup_overlays(self):
self._flash_overlay.alpha = 0
Expand Down
13 changes: 6 additions & 7 deletions test/gpio.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/env python

import os.path
import sys
from time import sleep

# GPIO
import RPi.GPIO as GPIO

BCM_PIN = 3

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP)
GPIO.add_event_detect(17, GPIO.FALLING)
GPIO.setup(BCM_PIN, GPIO.IN)
GPIO.add_event_detect(BCM_PIN, GPIO.FALLING)

while True:
sleep(.01)
if GPIO.event_detected(17):
if GPIO.event_detected(BCM_PIN):
print "pressed"

0 comments on commit 77a874b

Please sign in to comment.