30
edits
Changes
no edit summary
I made two tilt sensors out of ball bearings and bic pens and positioned them on either side of the motor at different angles.
When the motor/device is tilted in one direction, it will spin clockwise, and when tilted the other direction, counter-clockwise.
Originally I wanted to control a toy that would fall over and correct itself, but the motor it used takes a little more power than I was able to supply directly from the microprocessor, so this might be considered to be a prototype.
As for the aesthetic of the device, it would be fitted to the duty it was designed to perform such as a handle for a fishing pole, etc.
For testing, I affixed the components to a toilet paper tube with the tilt sensors pointing up a little bit so that they won't always be triggering.
(I let my friend borrow my Arduino, so there aren't any pictures of the "device" as a whole, but here are the main components!)
[[Image:http://i650.photobucket.com/albums/uu221/onebigword/photoPhoto.png]]
[[Image:http://i650.photobucket.com/albums/uu221/onebigword/photo2Photo2.png]]
And Here's the code!
int turn1 = 12; // choose the pins for controlling direction<br> int turn2 = 13;<br> int tilt1 = 4; // choose the input pin (for the tilt sensors)<br> int tilt2 = 5;<br> int val1 = 0; // variable for reading the pin status<br> int val2 = 0;<br> void setup() {<br> pinMode(turn1, OUTPUT); // declare turn pins as output<br> pinMode(turn2, OUTPUT);<br> pinMode(tilt1, INPUT); // declare tilt sensors as input<br> pinMode(tilt2, INPUT);<br>
[[User:S8brown/Project | Other Projects]]