User Manual
my_servo = servo.Servo(pwm) # Create my_servo with pwm signal
# LED for debugging
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT
# two buttons!
button_a = DigitalInOut(board.BUTTON_A)
button_a.direction = Direction.INPUT
button_a.pull = Pull.DOWN
button_b = DigitalInOut(board.BUTTON_B)
button_b.direction = Direction.INPUT
button_b.pull = Pull.DOWN
# NeoPixels!
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=1)
pixels.fill((0,0,0))
#################### log file for logging mode!
logfile = "/log.csv"
# check that we could append if wanted to
try:
fp = None
fp = open(logfile, "a")
print("File system writable!")
# pylint: disable=bare-except
except:
print("Not logging, trapeeze mode!")
# If we log, have some helper variables
logging = False
logpoints = 0
outstr = ""
# When its time to release the trapeze
release = False
while True:
if button_a.value: # A pressed
while button_a.value: # wait for release
pass
if fp: # start or stop logging
logging = not logging
print("Logging: ", logging)
time.sleep(0.25)
else:
my_servo.angle = 180 # open
if button_b.value: # B pressed
while button_b.value: # wait for release
pass
my_servo.angle = 0 # close
x, y, z = lis3dh.acceleration
# To keep from corrupting the filesys, take 25 readings at once
if logging and fp:
outstr += "%0.2F, %0.2F, %0.2F\n" % (x, y, z)
logpoints += 1
© Adafruit Industries
https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-
construction-kit
Page 140 of 201










