cricked
This commit is contained in:
parent
fef35d4017
commit
e48eb89fc5
1 changed files with 11 additions and 17 deletions
|
|
@ -3,17 +3,9 @@
|
||||||
# Dano Wall, Mike Barela for Adafruit Industries, MIT License, May, 2018
|
# Dano Wall, Mike Barela for Adafruit Industries, MIT License, May, 2018
|
||||||
#
|
#
|
||||||
import time
|
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
|
|
||||||
from busio import I2C
|
|
||||||
import board
|
import board
|
||||||
|
from digitalio import DigitalInOut, Direction, Pull
|
||||||
# Create seesaw object for Circuit Playground Express to talk to Crickit
|
from adafruit_crickit import crickit
|
||||||
i2c = I2C(board.SCL, board.SDA)
|
|
||||||
seesaw = Seesaw(i2c)
|
|
||||||
|
|
||||||
led = DigitalInOut(board.D13) # Set up Red LED
|
led = DigitalInOut(board.D13) # Set up Red LED
|
||||||
led.direction = Direction.OUTPUT
|
led.direction = Direction.OUTPUT
|
||||||
|
|
@ -23,13 +15,15 @@ button_A.direction = Direction.INPUT
|
||||||
button_A.pull = Pull.DOWN
|
button_A.pull = Pull.DOWN
|
||||||
|
|
||||||
# Create servos list
|
# Create servos list
|
||||||
servos = []
|
servos = [crickit.servo_1, crickit.servo_2]
|
||||||
for ss_pin in (17, 16): # Only use 2 servos, append , 15, 14 if using 4
|
|
||||||
pwm = PWMOut(seesaw, ss_pin)
|
# TowerPro servos like 500/2500 pulsewidths
|
||||||
pwm.frequency = 50
|
servos[0].set_pulse_width_range(min_pulse=500, max_pulse=2500)
|
||||||
_servo = servo.Servo(pwm, min_pulse=600, max_pulse=2500)
|
servos[1].set_pulse_width_range(min_pulse=500, max_pulse=2500)
|
||||||
_servo.angle = 90 # starting angle, middle
|
|
||||||
servos.append(_servo)
|
# starting angle, middle
|
||||||
|
servos[1].angle = 90
|
||||||
|
servos[0].angle = 90
|
||||||
|
|
||||||
def servo_front(direction):
|
def servo_front(direction):
|
||||||
if direction > 0:
|
if direction > 0:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue