Toy Car Phase 2
.png)
Python codes that
- makes a noise when either of the buttons are pressed
- Lights up red
- Spins
- Lights Up and Spins Simultaneously
Change- we tried to make it move forward last time but were unsuccessful. This time we are making the car spin since we have figured out on Python how to code spinning.
Our CPX device was coded through Python and through these codings I was able to make the CPX lights on the car light up red constantly. I also created a code where if you press a button it makes a noise just like if you press a button in the car it will make a noise. Lastly, there is a code that allows for the wheel to spin fully. This time we coded the car for the wheel to spin not for the car to mpve forward to ensure that our third code works as we were unsucessful to get it to move last time.
Supplies

- Adafruit Circuit Playground Express Basekit
- Continuous Rotation Micro Servo
- Alligator Clips to Male Wires
- 3D Printer
- Computer
- 3D printed car
- Wheels that can spin
- Python App
- Hot Glue
Instructions and Wiring
.png)
- Go to thingiverse and search toy car or use this link, https://www.thingiverse.com/thing:2741143 .
- Click the “Download All Files” button
- Open the .STL file in TinkerCAD
- Upload file to 3D printer
- The design doesn’t require supports to be printed
- Visit MakeCode for Adafruit
- Use code blocks to:
- On Start → Set Servo on A1 to 90°
- Input → On Button A Clicked → Set Servo on A1 to 0°
- Input → On Button B Clicked → Set Servo on A1 to 180°
- Connect your Circuit Playground Express (CPX) via USB
- Click “Download” in MakeCode, drag the .uf2 file to the CPX drive
- Done! The servo now responds to button presses
- Python code: # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""This example lights up all the NeoPixel LEDs red."""
from adafruit_circuitplayground import cp
import time
import board
import pwmio
from adafruit_motor import servo
# create a PWMOut object on Pin A2.
pwm = pwmio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)
my_servo = servo.Servo(pwm)
cp.pixels.brightness = 0.3
cp.pixels.fill((0, 0, 0)) # Turn off the NeoPixels if they're on!
while True:
cp.pixels.fill((50, 0, 0))
if cp.button_a:
cp.play_file("examples_dip.wav")
cp.pixels[2] = (0, 255, 0)
for angle in range(0, 180, 5): # 0 - 180 degrees, 5 degrees at a time.
my_servo.angle = angle
time.sleep(0.05)
else:
cp.pixels[2] = (0, 0, 0)
if cp.button_b:
cp.play_file("examples_dip.wav")
cp.pixels[7] = (0, 0, 255)
for angle in range(180, 0, -5): # 180 - 0 degrees, 5 degrees at a time.
my_servo.angle = angle
time.sleep(0.05)
else:
cp.pixels[7] = (0, 0, 0)
Insert servo motor into the slot
Secure with hot glue
Plug the servo wire into:
Orange → A1
Red → VOUT
Brown → GND
- Attach wheels to axles
- Mount CPX onto chassis with tape or screws
- Plug in battery pack or use USB for power
- Press A/B to move the servo and control the car
Printing Example
.png)
- Download and print the following STL files using a 3D printer. Use a raft and supports.
- These files were designed using TinkerCAD and
- Mount remixed from Adafruit’s Snap-fit Mount
Car:
Wheels and Rod: https://www.tinkercad.com/things/lIKVlscdAAl-spectacular-jaban?sharecode=uOAImMB7Q6ergd-J9_GlXFvjagYFXy-yAnGl_VzKAo4
Use these links and download them as STL documents. After downloading open Maker Bot. Then import the car document and make sure the printer type is set to sketch. When ready to print, export the document so it is able to convert to a makerbot document. Then do the same with the wheel and rod document to convert it into a makerbot document.