Introduction: Toy Car

These instructions will be used to create a Toy car with the ability to move forward and create sound and light.

Supplies

To start you will need the two halves of the car that is the top and bottom, the axles and wheels, the cpx, and the three wires to connect it to a battery, and a computer to create the code.

Step 1: Lets Make the Body

First, we want to make the car one piece, start by gluing the top to the bottom making sure it is properly aligned.

in this step, we may as well finish the body as well. take the two axles and put one axle through the two holes where the front and back wheels would be after which glue to wheels to each end of the axle.

Step 2: Coding the CPX

we will start with the basics of the code.

for this project, you will need the libraries - Bus device, circuitplayground, and motor.

make sure your cpx is properly plugged in so when it's saved it works.

Step 3: Importing the Libraries

so that all the code can properly run and to help in the making process we will import the libraries first.

by typing the code within the image you have successfully imported all the libraries needed to run the code.

Step 4: Two Button Setup

For our car we use the two buttons on the CPX both have the same function but allow for the pressing of a different button to still get the same result.


for this, we will use a while true loop

Step 5: Shine Bright

next, we will add lights to the CPX

these will be red and blue to mimic that of a police car.

the first image defines the base setting for our lights.

the second image will play either red or blue lights depending on their respective button



Step 6: Lets Make Some Noise

Now we will get our cpx playing a tone while it moves

these will play a tone on button press


Step 7: FORWARD!

adding this code will allow your car to move forward for 5 seconds

now that you are done with the code press save and unplug the cpx from your computer

Step 8: WIRING

When wiring you have three wires for this case they will be red yellow and brown

make sure before connecting the wires to the cpx you run them through the hole on the bottom

Brown - the ground wire

yellow - the function

red - the output


these correspond to the words on the CPX itself

after this is done you may now place the cpx on the top of the car and the motor under or on the back.

Step 9: Gotta Go Fast

now we have to glue the motor to the bottom of the car making sure it touches the ground (if the wheel attached does touch the ground the car will not move) be careful not to place the motor the wrong way or you might end up going backwards.