Accelerometer will not relay properdata

Hello everyone. My friend and I have recently started a project that involves an accelerometer, which we purchased from adafruit. We are able to calibrate it, but after calibration, the accelerometer still keeps spitting out data, and we cannot make it stop. In addition, the sensor only gives back the value -1G, even when we are moving the sensor upwards. It should change when we move it, yet it constantly relays back that value, which would equate to motionlessness. I will put our code below, and my questions are: 1, how do we get the arduino/sensor to stop providing data after calibration, and 2, how do we get the sensor to send back accurate values. Any response i]will be greatly appreciated.Thanks in advance!

const int zInput = A2;
const int buttonPin = 2;

// Raw Ranges:
// initialize to mid-range and allow calibration to
// find the minimum and maximum for each axis

int zRawMin = 512;
int zRawMax = 0;

// Take multiple samples to reduce noise
const int sampleSize = 12;

void setup()
{
; pinMode(2, INPUT);
digitalWrite(2,HIGH);
while( millis() < 5000);
zraw = analogRead(2);
}

{ analogReference(EXTERNAL);
Serial.begin(9600);
}

void loop()
{
float zRaw = ReadAxis(zInput);

if (digitalRead(buttonPin) == LOW)
{
AutoCalibrate(zRaw);
}
else
{

Serial.print(", Z: “);
Serial.print(zRawMin);
Serial.print(”-");
Serial.print(zRawMax);
Serial.println();
Serial.print(zRaw);

// Convert raw values to 'milli-Gs"
long zScaled = map(zRaw, zRawMin, zRawMax, -1000, 1000);

// re-scale to fractional Gs
float zAccel = zScaled / 1000.0;

Serial.print(" :: ");
Serial.print(zAccel);
Serial.println(“G”);

delay(500);
}
}

//
// Read “sampleSize” samples and report the average
//
float ReadAxis(float axisPin)
{
long reading = 0;
analogRead(axisPin);
delay(1);
for (float i = 0; i < sampleSize; i++)
{
reading += analogRead(axisPin);
}
return reading/sampleSize;
}

//
// Find the extreme raw readings from each axis
//
void AutoCalibrate(int zRaw)
{

if(buttonPin, HIGH) { //IF 1
{
Serial.println(“Calibrating”);
if (zRaw < zRawMin)
{
zRawMin = zRaw;
}

if (zRaw > zRawMax)
{
zRawMax = zRaw;

}
else(buttonPin, LOW); //IF 2
Serial.print(“Calibration Complete”);

}
}
}

Which accelerometer? Please read the "how to post" message and edit your post to add code tags.

Along with which accelerometer you're using, it would also be nice to know which tutorial you're following.

I think Adafruit does a great job on their tutorials but they often provide just a basic demonstration of how to use a sensor. The user is expected to modify the program to suit their needs.

If you don't know how to program, I suggest working through the tutorials provided by Arduino. Look under the "Learning" tab above for "Tutorials".