# accelerometer programming

Hi guys, I'm seriously new to this so please don't mind my noob-ness. Well currently doing a project for school and at the moment I have got my board to do a command where when I press a button, the board does a command. What I need help doing now is programming the accelerometer so cancel the command once it has gone past a certain point on its return to the center.

Okay that may sound confusing but basically in simple terms. - Click - command commences - accelerometer moves from center 0 to + 20 (to the left) - accelerometer starts to move towards 0 and Reach's +2 (because 0 is too accurate so between +2 and -2 count as 0 to cancel) - cancels command as it reaches 0

Easy enough, a simple IF/ELSE statement can do what you want. What kind/type of accelerometer are you using, a link would be helpful.

Really ? I didn’t know that was possible. I thought the output of an accelerometer was amplitude in g’s of force.
Who knew ? Since when do accelerometers measure degrees of motion ?

I would like to see how you do that. I am having trouble finding anything online to measure degrees of motion with accelerometer.
shoot me a link if you find anything…

HazardsMind: Easy enough, a simple IF/ELSE statement can do what you want. What kind/type of accelerometer are you using, a link would be helpful.

This is the accelerometer I have: http://pages.ebay.com/link/?nav=item.view&id=121325057592&alt=web

And this is the kit I have: http://pages.ebay.com/link/?nav=item.view&id=161099897306&alt=web

As i said I'm a noon at this and I'm totally confused. Is it possible for you to personal message me to run through the set up with me?

Thank you though

Why personal ? Anything we have to say to you about how to set up an acelerometer would be a waste of time if no one else were able to read it. All of the posts are intended to add to the knowledge base so when another person comes along trying to get the forum to do their homework for them they will have something to refer to .

Yea, no personals, keep it here so others can see your progress.

@raschemmel By themselves, they don't that is why I calibrate mine and use the map function to change the values from the accelerometer to degrees of motion. A gyro would be better thou.

I know that when I tilt my accelerometer, the X axis spits out (240,460) in the serial monitor and when it gets to a certain point, it starts going down from 460 or back up to 240, so that is the set range. The Y axis, when tilted left to right will output (240, 680) and I know it relates to 0-180 because of the way I tilt it. The Z axis is similar to the Y axis, but the values are slightly different. So X has a range of 90 degrees, and Y,Z have a range of 180 degrees.

It is quite accurate.

However, not all accelerometers are the same, so kutenda would need to provide the ranges of the XYZ axis', then change that to degrees of motion and then make the statements that (s)he is looking for.

Sounds like that would be ideal for a uControlled pan & tilt mount for a camera or 50-cal.

Exactly, which I why I made a pan and tilt camera mount for my RC truck and used that exact method.

Exactly, which I why I made a pan and tilt camera mount for my RC truck and used that exact method.

Did you post that project on the forum ? Are you using a Go-Pro with a 5.8 Ghz video transmitter connected to the NTSC vid out ? I guess there's no need for OSD & GPS with a truck.

Yea, but it is not a Go-Pro. I used this. Hidden Camera with this servo mount, Pan and Tilt Camera Platform

It works great in open areas, very clear, but since I live around a lot of buildings, the video quality is a little fuzzy.

You tilt your accelerometer and it reads a value, you equate that value to degrees of movement because you tilted it a certain number of degrees??? What does it read when you stop tilting and hold it at the same degree offset?? Either I am misinterpretting what you have said (which, I admit, is quite likely), or....

Having some degree of following this. are you sure you're talking about an accellerometer?

Wow ! I can't believe the price of the mount ! What a deal !

Sorry, meant to say "some degree of difficulty".

I think what he is saying is that Gravity causes the acelerometer to register aceleration and the amplitude is a function of the angle. (I could be wrong too. I am still trying to understand this)

I understand my explanation is a bit confusing. Basically I haven't connected anything yet and the components are still in their box but the project I was given by my teacher was to connects led lights that signify left and right. What the accelerometer does is cancel the command of the light being on when the accelerometer reachers center. Which in this case is between +2 and -2 figures are an example because I don't know how they actually calculate it

I hope that helps

raschemmel is correct.

I am using this accelerometer, ADXL335. I know that on a flat surface, the XYZ axis' spit out something like this (305,455,435) in the serial monitor. I then tilt it to find the full range of motion for each axis. Then once I have the ranges, I map them. I have a fluid level and a protractor to help with the angles and any offsets it may need to be accurate.

What the accelerometer does is cancel the command of the light being on when the accelerometer reachers center. Which in this case is between +2 and -2 figures are an example because I don't know how they actually calculate it

This sounds like a state change machine, the accelerometer is tilted in a certain direction, then brought back to its original position, the led that corresponds to the angle it was tilted to gets turned off.

I have the MMA7361, how do I program this to do the command?

kutenda: I have the MMA7361, how do I program this to do the command?

It has the XYZ pins on the board, so all you need to do is use an analogRead of each axis, and see what it produces.

There is a library and example sketch for that module here in this link.

Okay thank you, what about commanding it, how will I go about doing so because as I said I'm new and I don't know how to command

We'll get to that when you open it and learn how to get it to work. Once you are able to see the output from the axis, then you can start doing everything else.