Now lets connect ADXL335 to the Arduino and then compile and upload the above code.
Sensor placed in such way that Z axis is directed to front of car.(You can see it in the picture, on top of red box).
I run the program, type something and press enter in the Serial Monitor and then drive as fast as possible and then brake the car. Copy the values to the Google Docs Spreadsheet and create a chart for the values of Z axis (in which direction the acceleration occurs). But before creating charts lets understand how those numbers map to the real acceleration values in g. The Z axis can be directed downward and measure value (+1g), then direct it upward and measure again(-1g) and taking account that the measured values dependance on acceleration is linear, calculate which value correspond to 0g and which interval correspond to 1g interval. I get following results (approximate results)
0g -- 355
1g interval -- 70 interval
The measured values also contain a lot of noise, so we need to filter out them.
This is unfiltered chart: Z_i
This is filtered and converted to G chart: ((Z_i + Z_i+1) /2 - 355) / 70
This is filtered(another filter) and converted to G chart: ((Z_i + Z_i+1 + Z_i+2) / 3 - 355) / 705
In the above chart you can see the shift of gear from 1 to 2 and then brake. After car stops and acceleration is 0.