User Manual

import touchio
import audioio
import neopixel
import board
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=1)
pixels.fill((0,0,0))
# Create seesaw object
i2c = I2C(board.SCL, board.SDA)
seesaw = Seesaw(i2c)
# switch
switch = DigitalInOut(board.SLIDE_SWITCH)
switch.direction = Direction.INPUT
switch.pull = Pull.UP
# We need some extra captouches
touch2 = touchio.TouchIn(board.A2)
touch3 = touchio.TouchIn(board.A3)
# LED for debugging
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT
# Create drive (PWM) object
INFRARED_LED_SS = 13
my_drive = PWMOut(seesaw, INFRARED_LED_SS) # Drive 1 is on s.s. pin 13
my_drive.frequency = 1000 # Our default frequency is 1KHz
CAPTOUCH_THRESH = 850
# Commands, each 8 bit command is preceded by the 5 bit Init sequence
Init = [0, 0, 0, 1, 0] # This must precede any command
Calibrate = [1, 0, 1, 0, 1, 0, 1, 1] # the initial calibration
Up = [1, 0, 1, 1, 1, 0, 1, 1] # Move arms/body down
Down = [1, 1, 1, 1, 1, 0, 1, 1] # Move arms/body up
Left = [1, 0, 1, 1, 1, 0, 1, 0] # Twist body left
Right = [1, 1, 1, 0, 1, 0, 1, 0] # Twist body right
Close = [1, 0, 1, 1, 1, 1, 1, 0] # Close arms
Open = [1, 1, 1, 0, 1, 1, 1, 0] # Open arms
Test = [1, 1, 1, 0, 1, 0, 1, 1] # Turns R.O.B. head LED on
print("R.O.B. Start")
def IR_Command(cmd):
print("Sending ", cmd)
gc.collect() # collect memory now, timing specific!
# Output initialization and then command cmd
for val in Init+cmd: # For each value in initial+command
if val: # if it's a one, flash the IR LED
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
a = audioio.AudioOut(board.A0)
© Adafruit Industries
https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-
construction-kit
Page 145 of 201