Thursday, January 26, 2012

Project 1: Toy Hacking

Objective: This project is to hack an ordinary toy with a motor to be controlled by a microcontroller that one can program to do specific things.


My project used a remote control car in which the controller is a tilt sensor that allows the car to move forward while tilted down, or rotate 360 degrees in place while tilted up.

 I first tried soldering wires directly to the +/- terminals of the motor. From working with Professor Mason, we determined that the motor inside has an H-bridge to control the two functions of the car, move and rotate. Thus swapping between these modes is a matter of flipping the polarity. However, with the wires connected directly to the motor, the rotation would only result in spooling up the wires till it gets stuck.


I then tried to figure out how to interface directly to the controller. From working with Professor Mason, I found out that the tilt sensor works by creating a short between the two wires.

Thus I decided to disconnect the wires from the tilt sensor and allow the microcontroller to produce the short.

Given that a transistor is essentially an electronically controlled switch, I reasoned that it would be perfect for the job. I connected the two terminals that went to the tilt sensor to the collector and emitter of the transistor. Then the base was connected to output 2 of the microcontroller.

I am able to program the duration of the spin and movement in picaxe programming. The high output would short the terminals, and thus make the toy rotate. The low output would open the terminals and would open the terminals.

However, when I first tried this, I ran into a problem where the terminals were constantly shorted. From working with Prof. Mason, we determined that the output of the microcontroller isn't high enough to open the terminals on an NPN transistor. I then swapped it to a PNP transistor and everything worked as planned.
An LDR sensor was added to the circuit. My aim is to use the LDR sensor to control the turn of the toy.
Here is my coding for the LDR sensor. When light is shining on the sensor, the toy will just move forward. When the sensor is covered, the toy will turn ~90 degrees.



No comments:

Post a Comment