CircuitPy
Setup
Plug in your Circuit Playground into your computer
Press the small reset button in the center of the device
Go to this link and download the latest .UF2 file
Go you your file explorer and open the CPLAYBOOT drive
Drag and drop the .UF2 file you downloaded into the CPLAYBOOT drive
press the reset button the the device again
Open mu
When prompted to select mode, choose Adafruit CircuitPython
If all else fails, go to this link and read the instructions.
Challenges
Documentation
cp.pixels
a list of 10 pixels on the Circuit Playground Express
DESCRIPTION
You can use this list to set the color of the 10 pixels on your board. The color value of a pixel is represented by three numbers ranging from 0-255 for red, green, and blue in that order.
set pixel 1 to red
cp.pixels[0] = (255, 0, 0)
If you set the color of a pixel using the method shown above, the pixel will be set the that color, but it will not turn on. To turn on the pixels, you need to use the pixels.show() method.
set pixel 1 to red and turn it on
cp.pixels[0] = (255, 0, 0)
cp.pixels.show()
cp.play_tone(hertz, seconds)
plays a tone for a duration
DESCRIPTION
Plays a tone at a given hertz level for a given number of seconds. Human hearing range is from 40 - 20,000 hertz. Lower numbers are lower sound (bass) and higher numbers are high sounds (treble).
play 800 hz tone for 2 seconds
cp.play_tone(800, 2)
cp.button_a / cp.button_b
get input from the two buttons
DESCRIPTION
Returns True or False if the button is pressed.
Check if button A is pressed
if cp.button_a:
cp.switch
get input from the switch
DESCRIPTION
Returns True or False if the slide switch is in the left or right position.
Check switch
if cp.switch:
cp.temperature
get the ambient temperature of the room
DESCRIPTION
Returns a number representing the temperature of the room in celsius. To convert to fahrenheit, multiply it by 1.8 and then add 32.
Check if temperature is above 90F
if cp.temperature * 1.8 + 32 > 90:
cp.acceleration
get the rotation of the board in either the x, y, or z rotations
DESCRIPTION
When the board is held still in any given position, it is still being affected by gravity. Gravity is -9.8m/s2. So, at any given point in time, that value is being applied downward. For example, the values returned if the board is laying flat, facing up, are (0, 0, 9.8), because gravity is pulling on the sensor along the z axis. If you were to pick up the board and shake it, you'll find that you get much higher values. This is because the force with which you are shaking the board causes increased acceleration to be applied to the sensor along whichever axes you are shaking it.
Check if board is upside down
if cp.acceleration.z < 0:
cp.light
get the ambient light level of the room
DESCRIPTION
Returns the ambient light level of a room as a number from 0-320 with 320 being the brightest. A well-lit room is about 30.
Check if the lights are on
if cp.light > 30:
random.randrange(start, stop)
get a random number
DESCRIPTION
Returns a random number from a given range. Start value is inclusive and the stop value is exclusive.
Turn on the first pixel to a random color every two seconds
random.randrange(0, 255)