Xavier GERONIMI
/
ADXL335_3axe_accel_etallonage
acceleration et etallonage du zero
Fork of ADXL335_3axis_Accel by
main.cpp@3:7cef8e5abfe5, 2016-09-04 (annotated)
- Committer:
- shivamtripathi
- Date:
- Sun Sep 04 08:04:35 2016 +0000
- Revision:
- 3:7cef8e5abfe5
- Parent:
- 1:0490a15c76e4
- Child:
- 4:ee0a25a1c3dc
Accelerometer ( ADXL335 or GY-61) interfacing to FRDM-KL25Z
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shivamtripathi | 3:7cef8e5abfe5 | 1 | /**************************************************************************** |
shivamtripathi | 3:7cef8e5abfe5 | 2 | ****** 3-axis Accelerometer ADXL335 or GY-61 interfacing to FRDM-KL25Z ***** |
shivamtripathi | 3:7cef8e5abfe5 | 3 | ****** Author : SHIVAM TRIPATHI ****** |
shivamtripathi | 3:7cef8e5abfe5 | 4 | ***************************************************************************/ |
shivamtripathi | 3:7cef8e5abfe5 | 5 | |
bcostm | 0:c2d1ad5059da | 6 | #include "mbed.h" |
shivamtripathi | 3:7cef8e5abfe5 | 7 | |
shivamtripathi | 3:7cef8e5abfe5 | 8 | Serial pc(USBTX, USBRX); |
shivamtripathi | 3:7cef8e5abfe5 | 9 | AnalogIn analog_value1(A0); //Output of X-axis at analog pin A0 ........ (Refer pinout) |
shivamtripathi | 3:7cef8e5abfe5 | 10 | AnalogIn analog_value2(A1); //Output of y-axis at analog pin A1 |
shivamtripathi | 3:7cef8e5abfe5 | 11 | AnalogIn analog_value3(A2); //Output of z-axis at analog pin A1 |
shivamtripathi | 3:7cef8e5abfe5 | 12 | |
bcostm | 1:0490a15c76e4 | 13 | DigitalOut led(LED1); |
bcostm | 1:0490a15c76e4 | 14 | |
bcostm | 0:c2d1ad5059da | 15 | int main() { |
shivamtripathi | 3:7cef8e5abfe5 | 16 | int x,y,z; |
bcostm | 1:0490a15c76e4 | 17 | |
bcostm | 1:0490a15c76e4 | 18 | printf("\nAnalogIn example\n"); |
bcostm | 1:0490a15c76e4 | 19 | |
bcostm | 1:0490a15c76e4 | 20 | while(1) { |
shivamtripathi | 3:7cef8e5abfe5 | 21 | x = analog_value1.read_u16(); // Reads X-axis value and then converts in 16 bit format (3.3V --> 65535).........Analog values are read |
shivamtripathi | 3:7cef8e5abfe5 | 22 | y = analog_value2.read_u16(); // Reads Y-axis value and then converts in 16 bit format (3.3V --> 65535) |
shivamtripathi | 3:7cef8e5abfe5 | 23 | z = analog_value3.read_u16(); // Reads Z-axis value and then converts in 16 bit format (3.3V --> 65535) |
shivamtripathi | 3:7cef8e5abfe5 | 24 | printf("\r x = %d y = %d z = %d \n", x,y,z); //Prints output on pc Serial terminal (serial USB com driver is a must) |
shivamtripathi | 3:7cef8e5abfe5 | 25 | wait(0.5); // 500 ms |
shivamtripathi | 3:7cef8e5abfe5 | 26 | |
bcostm | 0:c2d1ad5059da | 27 | } |
bcostm | 0:c2d1ad5059da | 28 | } |