This commit is contained in:
Kattni Rembor 2018-05-29 16:40:13 -04:00
parent 965d5b5c6a
commit 2d0d86a21a
3 changed files with 40 additions and 41 deletions

View file

@ -6,7 +6,6 @@ from adafruit_motor import servo, motor
from busio import I2C from busio import I2C
import board import board
import time import time
import gc
i2c = I2C(board.SCL, board.SDA) i2c = I2C(board.SCL, board.SDA)
ss = Seesaw(i2c) ss = Seesaw(i2c)
@ -39,32 +38,32 @@ servos[0].angle = 180
while True: while True:
if switch.value: if switch.value:
# Switch is on, activate MUSIC POWER! # Switch is on, activate MUSIC POWER!
# motor forward slowly # motor forward slowly
motors[0].throttle = 0.2 motors[0].throttle = 0.2
# mote the head forward slowly, over 0.9 seconds # mote the head forward slowly, over 0.9 seconds
for a in range(180, 90, -1): for a in range(180, 90, -1):
servos[0].angle = a servos[0].angle = a
time.sleep(0.01) time.sleep(0.01)
# motor stop # motor stop
motors[0].throttle = 0 motors[0].throttle = 0
time.sleep(1) time.sleep(1)
# motor backwards slowly # motor backwards slowly
motors[0].throttle = -0.2 motors[0].throttle = -0.2
# move the head back slowly too, over 0.9 seconds # move the head back slowly too, over 0.9 seconds
for a in range(90, 180): for a in range(90, 180):
servos[0].angle = a servos[0].angle = a
time.sleep(0.01) time.sleep(0.01)
# calibration! its a *tiny* bit slower going back so give it a few ms # calibration! its a *tiny* bit slower going back so give it a few ms
time.sleep(0.007) time.sleep(0.007)
# motor stop # motor stop
motors[0].throttle = 0 motors[0].throttle = 0
time.sleep(1) time.sleep(1)
else: else:
# switch is 'off' so dont do anything! # switch is 'off' so dont do anything!
pass pass

View file

@ -89,34 +89,34 @@ while True: # Main Loop poll switches, do commands
#print(touch_vals) #print(touch_vals)
if touch2.raw_value > 3000: if touch2.raw_value > 3000:
print("Open jaws") print("Open jaws")
pixels.fill((50,50,0)) pixels.fill((50,50,0))
IR_Command(Open) # Button A opens arms IR_Command(Open) # Button A opens arms
elif touch3.raw_value > 3000: elif touch3.raw_value > 3000:
print("Close jaws") print("Close jaws")
pixels.fill((0,50,0)) pixels.fill((0,50,0))
IR_Command(Close) # Button B closes arms IR_Command(Close) # Button B closes arms
elif seesaw.touch_read(0) > CAPTOUCH_THRESH: elif seesaw.touch_read(0) > CAPTOUCH_THRESH:
print("Up") print("Up")
pixels.fill((50,0,50)) pixels.fill((50,0,50))
IR_Command(Up) IR_Command(Up)
elif seesaw.touch_read(1) > CAPTOUCH_THRESH: elif seesaw.touch_read(1) > CAPTOUCH_THRESH:
print("Down") print("Down")
pixels.fill((50,50,50)) pixels.fill((50,50,50))
IR_Command(Down) IR_Command(Down)
elif seesaw.touch_read(2) > CAPTOUCH_THRESH: elif seesaw.touch_read(2) > CAPTOUCH_THRESH:
print("Left") print("Left")
pixels.fill((50,0,0)) pixels.fill((50,0,0))
IR_Command(Left) IR_Command(Left)
elif seesaw.touch_read(3) > CAPTOUCH_THRESH: elif seesaw.touch_read(3) > CAPTOUCH_THRESH:
print("Right") print("Right")
pixels.fill((0,0,50)) pixels.fill((0,0,50))
IR_Command(Right) IR_Command(Right)
time.sleep(0.1) time.sleep(0.1)
pixels.fill((0,0,0)) pixels.fill((0,0,0))

View file

@ -1,4 +1,4 @@
# pylint: disable:wrong-import-position # pylint: disable=wrong-import-position
import time import time
import gc import gc
import pulseio import pulseio