accelerometer tutorial

Hi Everyone, my second time here?.no luck in the Spanish forum. So with my weird English I decided to come here…
I’m doing the accelerometer tutorial?everything works great arduino and the accelerometer is measuring?But my problem it is that I can’t understand some of the code of the tutorial
The colorful part of the code is the thing’s I don’t know what is referring to.
If anyone has the time to explain will be great.
what I wanted to do if anyone is interested…I’m trying to mesuare velocity, distance…etc using different equations.
Please have a moment to look this! :slight_smile:

int ledPin = 13;
int xaccPin = 7;
int yaccPin = 6;
int value = 0;
int accel = 0;
char sign = ’ ';

int timer = 0;
int count = 0;

void setup() {
beginSerial(9600);
pinMode(ledPin, OUTPUT);
pinMode(xaccPin, INPUT);
pinMode(yaccPin, INPUT);
}

int operateAcceleration(int time1) {
return abs(8 * (time1 / 10 - 500));
} // I don’t know what this equation is…can anyone explain a bit

void readAcceleration(int axe){
timer = 0;
count = 0;
value = digitalRead(axe);
while(value == HIGH) {
value = digitalRead(axe);
}
while(value == LOW) {
value = digitalRead(axe);
}
while(value == HIGH) { /
value = digitalRead(axe);
count = count + 1;
}
timer = count * 18; // here I don’t know what is 18? can anyone explain me this?
if (timer > 5000){
sign = ‘+’;
}
if (timer < 5000){
sign = ‘-’;
} // here I’ don’t get what is 5000 ?
//determine the value
accel = operateAcceleration(timer);

//Represent acceleration over serial port
if (axe == 7){
printByte(‘X’);
}
else {
printByte(‘Y’);
}
printByte(sign);
printInteger(accel);
printByte(’ ');

}
void loop() {
readAcceleration(xaccPin); //reads and represents acceleration X
readAcceleration(yaccPin); //reads and represents acceleration Y
digitalWrite(ledPin, HIGH);
delay(300);
digitalWrite(ledPin, LOW);
}

You can find a little more info on the output from that device and how it is decoded in this document: http://www.parallax.com/dl/docs/prod/acc/memsickit.pdf

Thanks for that! any suggestions for the rest of the code?