// 2009 mlab.taik.fi/paja // MEMSIC2125 Accelerometer int memsicXPin = 8; //pin to read x axis value int memsicYPin = 9; //pin to read y axis value void setup() { Serial.begin(9600); } void loop(){ int pulseX; // raw data of x axis from accelerometer int pulseY; // raw data of y axis from accelerometer int gravityX; // X axis gravity int gravityY; // Y axis gravity //value = pulseIn(pin, state); //Pin: Pin number (0 - 13, 14 to 19 are in analog input pins) //State: Specifies whether the puse to be mesured is low(0) or high(1) //value: the measured pulse duration will be stored. pulseX = pulseIn(memsicXPin, HIGH); gravityX = ((pulseX / 10) - 500) * 8; pulseY = pulseIn(memsicYPin, HIGH); // calculating the pulse to 1/1000 g gravityY = ((pulseY / 10) - 500) * 8; // Print values Serial.print("X: "); Serial.print(gravityX); Serial.print("\t"); Serial.print("Y: "); Serial.print(gravityY); Serial.println(); delay(100); }