Skip to content

Commit adf15aa

Browse files
committed
crickity
1 parent 942f6cc commit adf15aa

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

Trash_Panda/code.py

+12-29
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,29 @@
11
# Code for the Trash Panda tutorial with Adafruit Crickit and Circuit Playground Express
2-
# 5/2018 Dano Wall
3-
42
import time
5-
from digitalio import DigitalInOut, Direction
6-
from adafruit_seesaw.seesaw import Seesaw
7-
from adafruit_seesaw.pwmout import PWMOut
8-
from adafruit_motor import servo
9-
from busio import I2C
103
import board
4+
from digitalio import DigitalInOut, Direction
5+
from adafruit_crickit import crickit
116

12-
# Create seesaw object
13-
i2c = I2C(board.SCL, board.SDA)
14-
seesaw = Seesaw(i2c)
15-
7+
# built in LED
168
led = DigitalInOut(board.D13)
179
led.direction = Direction.OUTPUT
1810

19-
# Create servos list
20-
servos = []
21-
for ss_pin in (17, 16, 15, 14):
22-
pwm = PWMOut(seesaw, ss_pin)
23-
pwm.frequency = 50
24-
_servo = servo.Servo(pwm, min_pulse=600, max_pulse=2500)
25-
_servo.angle = 90 # starting angle, middle
26-
servos.append(_servo)
11+
# TowerPro servos like 500/2500 pulsewidths, make the wings flap a full 180
12+
crickit.servo_2.set_pulse_width_range(min_pulse=500, max_pulse=2500)
2713

2814
print("Its TRASH PANDA TIME!")
2915

3016
while True:
3117
print("tick")
3218
led.value = True
33-
servos[0].angle = 0
34-
time.sleep(0.5)
35-
servos[1].angle = 180
36-
time.sleep(0.5)
37-
servos[2].angle = 0
19+
crickit.servo_1.angle = 0
3820
time.sleep(0.5)
21+
crickit.servo_2.angle = 180
22+
time.sleep(1.0)
23+
3924
print("tock")
4025
led.value = False
41-
servos[0].angle = 180
42-
time.sleep(0.5)
43-
servos[1].angle = 0
44-
time.sleep(0.5)
45-
servos[2].angle = 180
26+
crickit.servo_1.angle = 180
4627
time.sleep(0.5)
28+
crickit.servo_2.angle = 0
29+
time.sleep(1.0)

0 commit comments

Comments
 (0)