Monday, February 15, 2016

Pinewood Derby and Arduino Coding

My middle son's Pinewood Derby for Cub Scouts was about a month ago. His pack usually has an "outlaw" division for dads, siblings, and other family members to submit cars. Usually I don't submit a car for the derby, but this year I decided to create a car powered by Arduino.

My original idea was to put a motion sensor on the car, have the Arduino detect that the car was moving, and start up a motor with a propeller. The way the project played out, I got the Arduino kit about 3 days before the Pinewood Derby, so I had to throw something together very quickly.

I cut the car into a basic platform, with a cut-out intended for the motor. I slapped some black paint on it to cover the wood and mounted the wheels. I didn't put any time into making it faster or straight because my intention was not to win a race.

Next I had to do something with the Arduino. I purchased the Arduino Uno with a basic electronics kit. The kit came with jumper wires, resistors, and numerous sensors. It was perfect! I spent a few hours installing the Arduino IDE and playing around with sample sketches. Now I was ready for my project.

My initial idea of driving a motor with the Arduino was doomed to fail. First off, I needed a 5V battery to power the Arduino. I really didn't have room on the car for the Arduino board, battery, and motor. (If I had more time, I would have used an Arduino micro.) Second, not being an electrical engineer, I didn't realize I needed a relay switch to power the Arduino and the motor from the same battery. This realization put my whole project in jeopardy.

At this point I was frantically scrambling to come up with something I could do for this project. I settled on mounting the active buzzer component, with a ball switch. I found a sketch that set up all the notes on the scale and played a melody repeatedly through the buzzer. I wired the buzzer into the Arduino board with the ball switch so that the melody only played when the car was angled downward. (This ensured that the car wasn't annoying everyone unless it was perched for a race.)

The project came together as a family effort. My oldest son helped me mount the board to the car while I figured out how to get the electronic components mounted. My middle son helped me figure out the first few notes of the Imperial March (think Darth Vader theme song) so I could program that into the sketch. I used the space for the motor to mount the battery, and was able to get something together. Here is a picture of the car.

The code I downloaded and modified to play the Imperial March is here on Github.

Even though the project didn't come out as I expected it, it had the desired effect. Numerous adults and scouts asked me about the car. They were all interested in how it worked and what it did. This was exactly the purpose of the project.

I wanted to show the scouts that something like the Pinewood Derby could be looked at through a different lens. I wanted to show the kids that technology can be used in different ways, even on a wooden block with wheels. Although it wasn't perfect, I'm still proud of my first IoT project!

No comments:

Post a Comment