linting
This commit is contained in:
parent
be2d7d9750
commit
54955e9378
3 changed files with 56 additions and 58 deletions
|
|
@ -1,13 +1,13 @@
|
|||
import time
|
||||
from busio import I2C
|
||||
import analogio
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import motor
|
||||
import board
|
||||
import time
|
||||
|
||||
light = analogio.AnalogIn(board.LIGHT)
|
||||
|
||||
|
||||
print("Wave on/off to turn")
|
||||
|
||||
# Create seesaw object
|
||||
|
|
@ -16,21 +16,18 @@ seesaw = Seesaw(i2c)
|
|||
|
||||
# Create one motor on seesaw PWM pins 22 & 23
|
||||
motor_a = motor.DCMotor(PWMOut(seesaw, 22), PWMOut(seesaw, 23))
|
||||
motor_a.throttle = 0 # motor is stopped
|
||||
motor_a.throttle = 0 # motor is stopped
|
||||
|
||||
while True:
|
||||
print((light.value,))
|
||||
# light value drops when a hand passes over
|
||||
if light.value < 4000:
|
||||
if motor_a.throttle:
|
||||
motor_a.throttle = 0
|
||||
else:
|
||||
motor_a.throttle = 1 # full speed forward
|
||||
if motor_a.throttle:
|
||||
motor_a.throttle = 0
|
||||
else:
|
||||
motor_a.throttle = 1 # full speed forward
|
||||
|
||||
while (light.value < 5000):
|
||||
while light.value < 5000:
|
||||
# wait till hand passes over completely
|
||||
pass
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# CircuitPython 3.0 CRICKIT demo
|
||||
import time
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import servo, motor
|
||||
from busio import I2C
|
||||
import board
|
||||
import time
|
||||
|
||||
i2c = I2C(board.SCL, board.SDA)
|
||||
ss = Seesaw(i2c)
|
||||
|
|
@ -38,32 +38,31 @@ servos[0].angle = 180
|
|||
|
||||
while True:
|
||||
if switch.value:
|
||||
# Switch is on, activate MUSIC POWER!
|
||||
# Switch is on, activate MUSIC POWER!
|
||||
|
||||
# motor forward slowly
|
||||
motors[0].throttle = 0.2
|
||||
# mote the head forward slowly, over 0.9 seconds
|
||||
for a in range(180, 90, -1):
|
||||
servos[0].angle = a
|
||||
time.sleep(0.01)
|
||||
# motor forward slowly
|
||||
motors[0].throttle = 0.2
|
||||
# mote the head forward slowly, over 0.9 seconds
|
||||
for a in range(180, 90, -1):
|
||||
servos[0].angle = a
|
||||
time.sleep(0.01)
|
||||
|
||||
# motor stop
|
||||
motors[0].throttle = 0
|
||||
time.sleep(1)
|
||||
# motor stop
|
||||
motors[0].throttle = 0
|
||||
time.sleep(1)
|
||||
|
||||
# motor backwards slowly
|
||||
motors[0].throttle = -0.2
|
||||
# move the head back slowly too, over 0.9 seconds
|
||||
for a in range(90, 180):
|
||||
servos[0].angle = a
|
||||
time.sleep(0.01)
|
||||
# calibration! its a *tiny* bit slower going back so give it a few ms
|
||||
time.sleep(0.007)
|
||||
# motor backwards slowly
|
||||
motors[0].throttle = -0.2
|
||||
# move the head back slowly too, over 0.9 seconds
|
||||
for a in range(90, 180):
|
||||
servos[0].angle = a
|
||||
time.sleep(0.01)
|
||||
# calibration! its a *tiny* bit slower going back so give it a few ms
|
||||
time.sleep(0.007)
|
||||
|
||||
# motor stop
|
||||
motors[0].throttle = 0
|
||||
time.sleep(1)
|
||||
# motor stop
|
||||
motors[0].throttle = 0
|
||||
time.sleep(1)
|
||||
else:
|
||||
# switch is 'off' so dont do anything!
|
||||
pass
|
||||
|
||||
# switch is 'off' so dont do anything!
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import time
|
||||
import gc
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
from busio import I2C
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
|
|
@ -6,8 +8,6 @@ import touchio
|
|||
import audioio
|
||||
import neopixel
|
||||
import board
|
||||
import time
|
||||
import gc
|
||||
|
||||
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=1)
|
||||
pixels.fill((0,0,0))
|
||||
|
|
@ -59,6 +59,7 @@ def IR_Command(cmd):
|
|||
seesaw.analog_write(INFRARED_LED_SS, 65535) # on
|
||||
seesaw.analog_write(INFRARED_LED_SS, 0) # off 2ms later
|
||||
time.sleep(0.013) # 17 ms total
|
||||
# pylint: disable=useless-else-on-loop
|
||||
else:
|
||||
time.sleep(0.015) # 17 ms total
|
||||
|
||||
|
|
@ -85,38 +86,39 @@ while True: # Main Loop poll switches, do commands
|
|||
if not switch.value:
|
||||
continue
|
||||
|
||||
#touch_vals = (touch2.raw_value, touch3.raw_value, seesaw.touch_read(0), seesaw.touch_read(1), seesaw.touch_read(2), seesaw.touch_read(3))
|
||||
#touch_vals = (touch2.raw_value, touch3.raw_value, seesaw.touch_read(0), seesaw.touch_read(1),
|
||||
# seesaw.touch_read(2), seesaw.touch_read(3))
|
||||
#print(touch_vals)
|
||||
|
||||
|
||||
if touch2.raw_value > 3000:
|
||||
print("Open jaws")
|
||||
pixels.fill((50,50,0))
|
||||
print("Open jaws")
|
||||
pixels.fill((50,50,0))
|
||||
IR_Command(Open) # Button A opens arms
|
||||
|
||||
|
||||
elif touch3.raw_value > 3000:
|
||||
print("Close jaws")
|
||||
pixels.fill((0,50,0))
|
||||
print("Close jaws")
|
||||
pixels.fill((0,50,0))
|
||||
IR_Command(Close) # Button B closes arms
|
||||
|
||||
elif seesaw.touch_read(0) > CAPTOUCH_THRESH:
|
||||
print("Up")
|
||||
pixels.fill((50,0,50))
|
||||
IR_Command(Up)
|
||||
print("Up")
|
||||
pixels.fill((50,0,50))
|
||||
IR_Command(Up)
|
||||
|
||||
elif seesaw.touch_read(1) > CAPTOUCH_THRESH:
|
||||
print("Down")
|
||||
pixels.fill((50,50,50))
|
||||
IR_Command(Down)
|
||||
print("Down")
|
||||
pixels.fill((50,50,50))
|
||||
IR_Command(Down)
|
||||
|
||||
elif seesaw.touch_read(2) > CAPTOUCH_THRESH:
|
||||
print("Left")
|
||||
pixels.fill((50,0,0))
|
||||
IR_Command(Left)
|
||||
print("Left")
|
||||
pixels.fill((50,0,0))
|
||||
IR_Command(Left)
|
||||
|
||||
elif seesaw.touch_read(3) > CAPTOUCH_THRESH:
|
||||
print("Right")
|
||||
pixels.fill((0,0,50))
|
||||
IR_Command(Right)
|
||||
|
||||
print("Right")
|
||||
pixels.fill((0,0,50))
|
||||
IR_Command(Right)
|
||||
|
||||
time.sleep(0.1)
|
||||
pixels.fill((0,0,0))
|
||||
|
|
|
|||
Loading…
Reference in a new issue