This version was originally released on September 8, 2020, on the eave of CircuitPython day. It is compatible with CircuitPython v5.3.1. The CircuitPython-v5.3.1 branch contains an archive of the python files and the accompanying examples for this code.
Changes:
- Code is much more efficient and leaner
- Code handles unforeseen errors better
- The edited version of the CLUE library has been absorbed by the Cutebot library
- The CLUE and Cutebot libraries are imported by using
from jisforjt_cutebot_clue import cutebot, clue
- Sensor functions are now properties and as such parenthesis (i.e. round brackets) are no longer required when calling the functions
- Sensor functions have been renamed - all letters are lowercase and the prefix "get" has been removed from all of them
Usage:
from jisforjt_cutebot_clue import cutebot, 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.p1 # Returns a value between 0 and 65535 from the P1 sensor extension pins
cutebot.p2 # Returns a value between 0 and 65535 from the P2 sensor extension pins
cutebot.sonar # Returns the distance between the ultrasound sensor and the object in front of it in centimeters (cm)
cutebot.tracking # Returns two true or false values - first for the left line sensor and second for the right line sensor.