changed the default logic for the buttons and contact pins to inverted - default high. changed circuit and circuit diagrams to accomodate for that.

This commit is contained in:
Patrick Tschuchnig 2019-09-19 08:58:21 +02:00
parent d5d79416e3
commit f617226879
2 changed files with 40 additions and 22 deletions

View File

@ -56,23 +56,23 @@ pin_blue, pin_green, pin_red
pin_start
Type: Input, Pull Up
Type: Input, Pull Down
Use: Start pin. If this is active, the game starts.
pin_stop
Type: Input, Pull Up
Type: Input, Pull Down
Use: Stop pin. If this is active, the game ends
pin_error
Type: Input, Pull Up
Type: Input, Pull Down
Use: This is to be attached to the game wire. If the wire is touched,
the pin is pulled up and an error is registered.
pin_shutdown
Type: Input, Pull Up
Type: Input, Pull Down
Use: Triggering this input causes a system shutdown.
GPIO Pinout for assembly:
@ -117,20 +117,18 @@ Circuit diagrams for the contact and button electronics:
All buttons are close-contact.
+3.3V DC ---+-----------+-----------+-----------+-------->
+3.3V DC ---+-----------+-------------------------------->
| | | |
R2 R4 R4 R4
| | | |
start \ stop \ shutdown \ error \
contact \ contact \ button \ contact \
+----+ +----+ +----+ +----+
| | | | | | | |
| P_32 | P_37 | P_32 | P_32
\ \ \ \
\ \ \ \
\ \ \ \
* * * *
| | | |
R1 R3 R5 R7
| | | |
+-----+ +-----+ +-----+ +-----+
| | | | | | | |
R2 P_32 R4 P_37 R6 P_36 R8 P_33
| | | |
GND --------+-----------+-----------+-----------+-------->
LED Strip controller and driver:
@ -190,13 +188,9 @@ and the other 3 the ground connections for the corresponding LED colour.
Part list:
Resistors:
R1............1,800 Ohm
R2...........10,000 Ohm
R3............1,800 Ohm
R4...........10,000 Ohm
R5............1,800 Ohm
R6...........10,000 Ohm
R7............1,800 Ohm
R8...........10,000 Ohm
R9............1,000 Ohm
R10..........10,000 Ohm
@ -454,7 +448,7 @@ def handle_events():
exit_application()
# shutdown raspberry if shutdown pin is detected
if GPIO.input(pin_shutdown):
if not GPIO.input(pin_shutdown):
shutdown_raspberry()
def exit_application():
@ -715,7 +709,7 @@ while True:
# event handling for if the start button is pushed
#wait for the user to press start button
if GPIO.input(pin_start) and not pin_start_inhibit:
if not GPIO.input(pin_start) and not pin_start_inhibit:
# change game state to running and not ending
game_running = True
game_ending = False
@ -753,7 +747,7 @@ while True:
pin_start_inhibit = False
# add errors if error pin is detected, only once per 500 ms
if GPIO.input(pin_error):
if not GPIO.input(pin_error):
if not error_added:
errors += 1
error_added = True
@ -791,7 +785,7 @@ while True:
#pygame.display.flip()
# if another push of start is detected (i.e. the game is ending!)
if GPIO.input(pin_stop):
if not GPIO.input(pin_stop):
# change led colour to red
change_led_colour(200, 0, 200)

24
pud_test.py Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python
#coding=utf-8
import signal
import sys
import os
import time
import RPi.GPIO as GPIO
############################################
############## END OF IMPORTS ##############
# GPIO for Buttons
pin_start = 36
# initialise gpio
GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin_start, GPIO.IN)
while True:
print(GPIO.input(pin_start))
time.sleep(1)