Toy Car Phase 2
.png)
Introduction:
This project is part of a beginner-friendly engineering course assignment where we were tasked with building and programming a small, functional toy car using a Circuit Playground Express (CPX), a servo motor, and a 3D-printed chassis. The goal was to explore the basics of electronics, coding, and mechanical design in a fun, hands-on way. In this phase, we focused on assembling the car, integrating the servo motor for movement, and uploading custom code using Microsoft MakeCode.
Whether you're a student working on a similar project or just someone curious about how to build a simple programmable car, this guide will walk you through the process step by step. From gathering materials to coding and testing, we’ll show you what worked, what we learned, and how you can build your own version.
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 move forward to ensure that our third code works as we were unsucessful to get it to move last time.
Connecting and Assembling the Servo Motor
To give the toy car motion, we used a small servo motor connected to the Circuit Playground Express (CPX). Here’s how we assembled it step-by-step:
- Attach the Servo to the Car Chassis
- Start by aligning the servo motor with the designated servo slot in the 3D-printed chassis. If your chassis doesn’t have a built-in mount, use hot glue or double-sided tape to secure the motor firmly. Make sure the servo horn (arm) is positioned so it can freely rotate and control the movement, usually near the front wheels or steering component.
- Connect the Servo Wires to the CPX
- The servo motor has three wires:
- Orange (Signal): This wire goes to pin A1 on the CPX.
- Red (Power): Connect this to the VOUT pad.
- Brown (Ground): Connect this to the GND pad.
- Use alligator clips or jumper wires to make these connections, and double-check that each wire is securely attached.
- Powering the Servo
- Since the servo draws more power than the CPX can supply via USB alone, make sure your CPX is plugged into your laptop or a battery pack with enough voltage (we recommend using a USB battery bank if not connected to a computer).
- Test the Range of Motion
- Before attaching the wheels or axles, use a simple MakeCode program to rotate the servo. This helps you confirm that the motor is connected properly and responds to input. Adjust the position of the servo horn as needed to center it when the power is on.
By following these steps, your servo motor should be fully connected and ready to be programmed. Once the physical setup is complete, you can move on to coding the motion using MakeCode blocks.
Now that the servo motor is mounted and connected to the Circuit Playground Express (CPX), it’s time to complete the build and test the car. The goal of this final stage is to secure all components, upload your code, and make sure everything functions smoothly when powered.
Start by firmly attaching the CPX to the chassis using Velcro, double-sided tape, or zip ties. Make sure it’s secure but accessible, especially the USB port, in case you need to make adjustments to your code later. Check that your servo wires are neat and not hanging loose where they could interfere with the wheels or ground.
Next, connect the front axle, wheels, or any other moving parts that interact with the servo. Double-check the alignment to ensure the car will move smoothly. The servo horn should be attached in a position that gives it full range of motion without over-rotating or getting stuck.
With the hardware in place, plug your CPX into your computer and upload your MakeCode program. It’s a good idea to test a simple version of your code first to make sure the servo is responding correctly. If it doesn’t move the way you expect, try adjusting the rotation angles or pauses between commands.
Once the code is working, plug in your portable battery or other power source. If everything is wired correctly, the CPX should light up and run your program. Place the car on a flat surface and observe how it moves. If it turns too sharply or doesn’t stay straight, tweak the servo angles or reposition the horn.
If needed, experiment with different timing in the code to fine-tune how the car moves. Adding friction to the wheels, adjusting the balance of the chassis, and keeping the wires tidy can all make a noticeable difference in performance. Once it’s running consistently, you’re done—your toy car is ready to drive!
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.