Accelerometer Project

I have an Arduino Uno board and an accelerometer (pictured below). I'm completely new to Arduino, and I need to know how to connect the accelerometer to the Uno board, and furthermore, how to program it to give me numeric values on my computer. I'm a complete noob at this, sorry! But I would really appreciate some help.

Look at the accelerometer for any markings that tell you the manufacturer and part number. If you find the part number, Google 'Arduino' plus that part number to see whether somebody has already solved the problem for you. If not, you need to hunt down documentation for that device which will tell you how to power it and how to interface to it. Manufacturers typically make this sort of information readily available but to find it, first you need to identify the device.

From the (reversed, slightly blurry) picture it looks like you connect +5 and Gnd to your board (maybe those two holes to the right of the XYZ grid) and then you can get analog voltages from the X, Y, and Z holes. Use analog input pins to measure the analog voltages. With each axis facing UP (+1g) and DOWN (-1g) record the +1g and -1g values for all three inputs and you can then translate from analog input values to g's.

Ok, so I figured out how to wire it (I think, but I won't be able to know for sure until I get the code). But I have NO idea what I'm doing as far as code. I'm measuring all 3 axes, and I want to get values in "Gs." I'm using Analog Inputs 3, 4, and 5.

The analogRead(3) will give you a number between 0 and 1023. Display that number. Turn the accelerometer to find the maximum (1G) and minimum (-1G). Then you can convert to milliG:

int XMilliG = map(analogRead(3), XMinimum, XMaximum, -1000, 1000);

Repeat for Y and Z.

I have pasted this one the QCN page, maybe it will stir up some interest

I did a little accelerometer script recently to help my daughter measure the period of a pendulum swinging. When I first started getting readings, I was a bit surprised. I was expecting zeros when it was at rest. But gravity is still having an effect on it, so you will get readings even when the sensor is not in motion. There, now hopefully, you won't be as confused as I was when I first started getting readings.



Ok, so I gave up on this accelerometer and got a new one which is connected into the DIGITAL inputs on the Arduino, not Analog. My code is shown below and works but it gives values between 3000ish and 7000ish where 5000 is equivalent to 1g. What would I add to the code in order for it to just give me a g value instead of the number and having me figure it out?

const int xIn = 2; // X output
const int yIn = 3; // Y output

void setup() {

void loop() {
// variables to read the pulse widths:
int pulseX, pulseY;

pulseX = pulseIn(xIn,HIGH); // Read X pulse
pulseY = pulseIn(yIn,HIGH); // Read Y pulse

// Display result
Serial.print(pulseX); // Display X and Y values


it gives values between 3000ish and 7000ish where 5000 is equivalent to 1g.

Are you sure 5000 isn't equivalent to 0G? That's what I would expect. With the X axis pointing up I would expect a +1G value (7000?) and with the X axis pointing down I would expect a -1G value (3000?). The mid point (5000) should be about 0G. Once you have determined +1G and -1G values you can use the code already provided to translate to milliG:

int XMilliG = map(pulseIn(xIn,HIGH), XMinimum, XMaximum, -1000, 1000);