Skip to content

Compatibility with CircuitPython v5.3.0

Compare
Choose a tag to compare
@jtobinart jtobinart released this 27 Sep 20:27
d11ed99

This version was originally released on July 27, 2020, and was compatible with CircuitPython v5.3.0. The CircuitPython-v5.3.0 branch contains the python files and the accompanying examples for this code.

This version is a higher-level library that requires you to use two files to control all the features of Adafruit's CLUE dev board and ElecFreaks' Smart Cutebot. Due to issues with the i2c clock frequency, a special instance of busio.I2C was created and shared with both the edited version of the CLUE and Cutebot libraries. This version of the CLUE library contains all the features of the original except for the touch features.

Usage:

import cutebot
from cutebot import clue

cutebot.playTone(tone, duration)
 # Parameters:
    # tone (int) - the frequency of the tones/music notes you want to play
    # duration (float) - the number of seconds you want to play the tone

cutebot.headlights(whichLight, colors)
cutebot.pixels(whichLight, colors)
 # Parameters:
    # whichLight (integer) - there are four states to choose from
        # 0 = Sets both lights to off
        # 1 = Sets left light only
        # 2 = Sets right light only
        # 3 = Sets both lights
    # colors (array of three integers) - RGB color that will be displayed
        # colors[0] = red
        # colors[1] = green
        # colors[2] = blue

cutebot.lightsOff()        # Turn off all LEDs

cutebot.motors(leftSpeed, rightSpeed)
 # Parameters:
    # leftSpeed (int) - speed of the left motor (Speed Range: full backwards = -100, stop = 0, and full forwards = 100)
    # rightSpeed (int) - speed of the right motor (Speed Range: full backwards = -100, stop = 0, and full forwards = 100)

cutebot.motorsOff()      # stops Cutebot's motors

cutebot.servoMaxAngleInDegrees = 180         # Set to your servos' maximum degree angle
cutebot.servos(whichServo, angleInDegrees)
 # Parameters:
    # whichServo (integer) - there are three states to choose from
        # 1 = S1 Servo (0x05)
        # 2 = S2 Servo (0x06)
        # 3 = S1 and S2 Servos
    # angleInDegrees (integer) - the angle in degrees that the servo(s) should be set to

cutebot.centerServos()      # centers both servos

cutebot.getP1()          # Returns a value between 0 and 65535 from the P1 sensor extension pins
cutebot.getP2()          # Returns a value between 0 and 65535 from the P2 sensor extension pins
cutebot.getSonar()        # Returns the distance between the ultrasound sensor and the object in front of it in centimeters (cm)
cutebot.getTracking()        # Returns two true or false values - first for the left line sensor and second for the right line sensor.