View Full Version : Accelerometer help
01-26-2007, 07:30 AM
im relatively new with programming but my class is doing a project that involves an accelerometer and i was trying to figure out how to have the accelerometer read a certain angle (ie 30 degrees) and when the tilt is beyond 30 or less than negative 30, have an alarm buzzer or led turn on.··· i have yet to figure it out and was looking for some help with adding things to parallax's basic accelerometer code.
email - firstname.lastname@example.org (mailto:email@example.com)
01-26-2007, 09:14 AM
First you need to figure out how the accelerometer talks to the outside world and then the program for the stamp turning on the buzzer is to test the angle and when it is bigger that the set point bring the pin the buzzer is attached to high. You need to do more research.
01-26-2007, 10:27 AM
Take a look at the Memsic 2125 Dual-axis Accelerometer from Parallax (http://www.parallax.com/detail.asp?product_id=28017). I have it. It is simple to interface to the Stamp . . . there are complete instructions and sample code available at the site I parenthesized above.
I would empiricaly determine 30 degrees and minus 30 degrees from vertical with a protractor while running some code that displays the Memsic raw output . . . which will not be anything even close to 30, plus or minus! But, as you described your requirement, you do not need to display the actual degree of tilt, you need to sound a buzzer or turn on an LED when 30 degrees of tilt, either way, is exceeded.
Just tilt the platform on which you have mounted the Memsic (perhaps it will be the breadboard on the Parallax Board of Education?) 30 degrees one way and write down the Memsic raw output number. Then, tilt it to 30 degrees in the opposite direction and write down the Memsic raw output number. Next write a PBasic program that simply watches the Memsic raw output. When the output exceeds either number which you have previously recorded, have the Stamp turn on the buzzer or LED.
If you need help figuring out how to turn on the LED, simply download the free "What's a Microprocessor?" from Parallax. The·buzzer thing is a different free download book . . . look around on their site for it.
You are what you write.