Sumit Pandey
/
adxl335_mbed_serial
transmission of calibrated accelerometer data to the computer for Air Hockey.
Revision 0:6754c50b1d75, committed 2013-10-27
- Comitter:
- sumitpuneet
- Date:
- Sun Oct 27 18:30:26 2013 +0000
- Commit message:
- accelerometer data transmission adxl335
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 6754c50b1d75 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Oct 27 18:30:26 2013 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +AnalogIn inputx(p20); // input pins 20,19,18 for x,y,z axis respectively. +AnalogIn inputy(p19); +AnalogIn inputz(p18); +Serial pc(USBTX,USBRX); //Serial class for transmission of serial data + +int main() { +pc.baud(9600); // fixing a constant baud rate of 9600 bps at which mbed will interact with computer +float cal_x=0,cal_y=0,cal_z=0; //caliberation variables +int x=0,y=0,z=0; // variables for x,y,z axes +int i=100; +while(i--) //small timed loop to caliberate the accelerometer with currentl position of the accelerometer +{ +cal_x=inputx*100; +cal_y=inputy*100; +cal_z=inputz*100 - 10; +} +while(1) + { + x=4*(cal_x - inputx*100); + y=4*(cal_y - inputy*100); + z=4*(inputz*100 - cal_z); + pc.printf("%d,%d,%d *",x+50,y+50,z+50); //passing the caliberated x,y,z values to the computer. + } + } \ No newline at end of file
diff -r 000000000000 -r 6754c50b1d75 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Oct 27 18:30:26 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9c8f0e3462fb \ No newline at end of file