The Arduino Inventor's Guide (47 page)

BOOK: The Arduino Inventor's Guide
5.56Mb size Format: txt, pdf, ePub
Assemble the Starting Gate

To build the starting gate, you’ll need a piece of cardboard that is 2.5 × 1 inches and a short length of bamboo skewer or thin coffee stirring rod. This will serve as an axle for the starting gate. To start, add a small bead of glue to the edge of the starting gate piece, and glue the servo horn on so that the hub hangs just off the edge, as shown in
Figure 9-19
.

FIGURE 9-19:
Gluing the servo horn onto the edge of the starting gate

Cut down the bamboo skewer to 3.5 inches. Place a line of glue along the edge, and line the axle up with the hub of the servo horn, as shown in
Figure 9-20
.

FIGURE 9-20:
Gluing the axle to the starting gate

Plug in your Arduino and push the reset button to reset the position of the servo. Remember that the code will start off with the servo in the 0 degree position; this will be the down position, where the starting gate is holding the car in place. To place the starting gate into the support tower, first insert the axle into the hole on the side piece opposite of the servo, as shown in
Figure 9-21
. Keep in mind that when the gate opens, it will rotate clockwise.

FIGURE 9-21:
Inserting the axle into the side piece for the starting gate

The finished starting tower with the gate is shown in
Figure 9-22
.

FIGURE 9-22:
Completed starting tower

Now you need a track. You can use a standard Hot Wheels track, which will fit on the lower support, or build your own track. If you want to use a Hot Wheels track, skip ahead to “
Add the Photoresistor
” on page
270
.

Build Your Own Track

To build your own track, you’ll need at least one sheet of cardstock, cut down to 3.5 × 11 inches. You can make several lengths of track and tape them together for a longer track, but for our example, we’ll just use a single track.

You’ll fold two side rails on the track. On each side, measure and mark a line that is a quarter inch from the edge. Now, fold along the lines so that you have a quarter-inch lip on each side of your track. (It’s often helpful to use a metal ruler or the edge of a table to make a nice straight fold in cardstock.) The lip will keep your car from flying off the track and also adds a small amount of structural integrity. Your track should look similar to the one pictured in
Figure 9-23
.

Now, using a small handheld hole punch, make a hole about a half inch from the end of your track for your photoresistor. If you don’t have a hole punch, a craft knife or sharp pencil will also work. Just be careful when cutting through the paper, and always use a cutting mat when using a knife. The hole needs to be just large enough for the head of the photoresistor to fit inside.

FIGURE 9-23:
Completed track with two sides folded up

Add the Photoresistor

Whether you’re using a homemade track or a standard toy track, the next step is to add the photoresistor at the bottom of the ramp. The photoresistor will be your finish-line sensor. (There is a small hole at the end of a standard Hot Wheels track, slightly smaller than the diameter of the photoresistor sensor. Thankfully, the plastic track is flexible enough that you can simply press the head of the photo-resistor through this hole.)

Remove the photoresistor from the breadboard and bend the legs at a right angle along the head so that it looks like
Figure 9-24
.

FIGURE 9-24:
Bend the head of the photoresistor at a right angle.

Insert the head of the photoresistor through the hole in your track. Make sure that the photoresistor does not stick out too much, or your car will catch on it; the car should be able to roll over the sensor without interference. With the legs bent at right angles, you should be able to tape them down securely to the bottom side of the track, as shown in
Figure 9-25
.

FIGURE 9-25:
Securing the photo resistor to the race track

Reconnect the photoresistor to your breadboard using a pair of male-to-female jumper wires. If you extended the track too far and can’t reach the breadboard, add more male-to-female jumpers to extend your wires as needed.

FEEL THE NEED FOR SPEED? CALCULATING AVERAGE SPEED

With this project you can accurately measure how long it takes the car to roll down the ramp and cross the finish line, but you don’t know how
fast
the car is moving—or do you?

Well, you have the total time it takes for the car to reach the bottom of the track, and you know the length of the track. With these two pieces of information, you can
estimate
how fast the car is moving. We describe this as an estimate because it’s really an average speed, as opposed to the exact speed of your car when it meets the sensor at the bottom of the ramp. If you watch as the car rolls down, you’ll see that it starts at the top of the ramp unmoving, then moves slowly, and then continues to speed up as it goes down the track.

Average speed is defined as distance traveled per unit of time. So, to find the average speed, you need to measure the length of the track and divide this value by the time elapsed.

Our track measures about 8.5 inches from the starting gate to the finish-line sensor, and in our last test we had a time of 0.581 seconds. If we divide these two numbers, we get an average speed of 14.6 inches per second.

Remember that this is the
average
speed of the car. For our simple setup with a straight ramp, this is roughly how fast the car is moving at the middle of the ramp, and since it wasn’t moving at the top of the ramp, this means it was moving at twice this speed at the bottom of the ramp. How fast is your car moving?

Other books

Forbidden Reading by Lisette Ashton
Light From Heaven by Jan Karon
Faded Glory by David Essex
Home Before Dark by SUSAN WIGGS
The Debt 3 by Kelly Favor
Cupcakes & Chardonnay by Gabriel, Julia
The Revengers by Donald Hamilton
Looks to Die For by Janice Kaplan