Update the cables
This commit is contained in:
19
README.md
19
README.md
@@ -25,4 +25,23 @@ inet6 fe80::7e2c:ada5:5de7:9a2c/64
|
|||||||
|
|
||||||
## Cables
|
## Cables
|
||||||
|
|
||||||
|
From right to left
|
||||||
|
|
||||||
|
```
|
||||||
|
..............................
|
||||||
|
. ---------- 1x .
|
||||||
|
. 2x .
|
||||||
|
. 3x .
|
||||||
|
. xx .
|
||||||
|
. ooooo 4x .
|
||||||
|
. ooooo xx .
|
||||||
|
. ooooo xx .
|
||||||
|
. xx .
|
||||||
|
. xx .
|
||||||
|
. .
|
||||||
|
|
||||||
|
1: white
|
||||||
|
2: purlple
|
||||||
|
3: yellow
|
||||||
|
4: black
|
||||||
|
```
|
||||||
|
|||||||
61
clock.py
61
clock.py
@@ -1,61 +0,0 @@
|
|||||||
import pigpio
|
|
||||||
import RPi.GPIO as GPIO
|
|
||||||
import time
|
|
||||||
import os
|
|
||||||
|
|
||||||
from motor import Motor # Models the motor
|
|
||||||
|
|
||||||
# Constants
|
|
||||||
SERVO1_PIN = 18
|
|
||||||
SERVO2_PIN = 19
|
|
||||||
|
|
||||||
BUTTON1_FWD = 5
|
|
||||||
BUTTON1_BWD = 6
|
|
||||||
BUTTON2_FWD = 17
|
|
||||||
BUTTON2_BWD = 27
|
|
||||||
SHUTDOWN_BTN = 26
|
|
||||||
|
|
||||||
STEP = 2
|
|
||||||
LOOP_DELAY = 0.3 # In seconds
|
|
||||||
|
|
||||||
# Local pi
|
|
||||||
pi = pigpio.pi()
|
|
||||||
if not pi:
|
|
||||||
os.exit()
|
|
||||||
|
|
||||||
# Setup the controls
|
|
||||||
GPIO.setmode(GPIO.BCM)
|
|
||||||
for btn in [BUTTON1_FWD, BUTTON1_BWD, BUTTON2_FWD, BUTTON2_BWD, SHUTDOWN_BTN]:
|
|
||||||
GPIO.setup(btn, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
|
||||||
|
|
||||||
# Setup motors
|
|
||||||
m1 = Motor(pi, SERVO1_PIN)
|
|
||||||
m2 = Motor(pi, SERVO2_PIN)
|
|
||||||
|
|
||||||
# Main
|
|
||||||
try:
|
|
||||||
while True:
|
|
||||||
# Inputs shutdown
|
|
||||||
if GPIO.input(SHUTDOWN_BTN) == GPIO.HIGH:
|
|
||||||
os.system("sudo shutdown now")
|
|
||||||
|
|
||||||
# Motors
|
|
||||||
if GPIO.input(BUTTON1_FWD):
|
|
||||||
m1.inc(STEP)
|
|
||||||
elif GPIO.input(BUTTON1_BWD):
|
|
||||||
m1.inc(-STEP)
|
|
||||||
if GPIO.input(BUTTON2_FWD):
|
|
||||||
m2.inc(STEP)
|
|
||||||
elif GPIO.input(BUTTON2_BWD):
|
|
||||||
m2.inc(-STEP)
|
|
||||||
|
|
||||||
time.sleep(LOOP_DELAY)
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
pass
|
|
||||||
|
|
||||||
finally:
|
|
||||||
del m1
|
|
||||||
del m2
|
|
||||||
pi.stop()
|
|
||||||
GPIO.cleanup()
|
|
||||||
Reference in New Issue
Block a user