/ Trash_Panda / code.py
code.py
 1  # SPDX-FileCopyrightText: 2018 Limor Fried/ladyada for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  # Code for the Trash Panda tutorial with Adafruit Crickit and Circuit Playground Express
 6  import time
 7  import board
 8  from digitalio import DigitalInOut, Direction
 9  from adafruit_crickit import crickit
10  
11  # built in LED
12  led = DigitalInOut(board.D13)
13  led.direction = Direction.OUTPUT
14  
15  # TowerPro servos like 500/2500 pulsewidths, make the wings flap a full 180
16  crickit.servo_1.set_pulse_width_range(min_pulse=500, max_pulse=2500)
17  crickit.servo_2.set_pulse_width_range(min_pulse=500, max_pulse=2500)
18  
19  print("Its TRASH PANDA TIME!")
20  
21  while True:
22      print("tick")
23      led.value = True
24      crickit.servo_1.angle = 0
25      time.sleep(0.5)
26      crickit.servo_2.angle = 180
27      time.sleep(1.0)
28  
29      print("tock")
30      led.value = False
31      crickit.servo_1.angle = 180
32      time.sleep(0.5)
33      crickit.servo_2.angle = 0
34      time.sleep(1.0)