Window Painting Robot (arduino, processing, accelerometer)

 by Mizchief100
Featured

Step 7: Accelerometer (Optional)

100_5907.JPG
Now to attach the accelerometer! Mine runs of off 5v as many do so I simply wired the red and black wires straight to the arduino 5v pin and ground pins respectively. My accelerometer is analog (I think most are but am not 100% sure), so I sent the yellow wire to the a0 analog pin on the arduino. All set.

Before attaching it run a simple program that reads the accelerometer values and prints them to the screen. Find the direction that the accelerometer should be held at to get the greatest value. Then turn the accelerometer a complete 180 degrees and you should be getting the minimum value that the accelerometer will read. My max was around 600 and my min was around 400, but yours could be quite different! Write these down as you will need them for calibrating the robot in the processing sketch.

When you mount it to the robot, make sure that it will give this maximum reading when the robot is attached to the wall and "looking up" or pointed to climb upwards on the window.

To give a little more information on how this is used, the arduino code reads the accelerometer value every millisecond and uses a buffer by averaging 20 of these values before using the averaged value as the robots "current" position in the code. Using this filter my robot turns exact angles to within about 3 degrees (tough to estimate) of the desired value. This small imprecision is most likely due to the motors slowing down before stopping for an extremely short time after they have been set to neutral. 
 
Remove these adsRemove these ads by Signing Up
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!