This consists of code to receive the transmitted characters and display them on red LEDs.
Fork of ADXL345_HelloWorld by
Revision 0:9e92575dece6, committed 2010-08-03
- Comitter:
- aberk
- Date:
- Tue Aug 03 08:31:00 2010 +0000
- Child:
- 1:1fd6658651c4
- Commit message:
- Version 1.0
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ADXL345_lib.lib Tue Aug 03 08:31:00 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/aberk/programs/ADXL345_lib/latest \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Aug 03 08:31:00 2010 +0000
@@ -0,0 +1,36 @@
+#include "ADXL345.h"
+
+ADXL345 accelerometer(p5, p6, p7, p8);
+Serial pc(USBTX, USBRX);
+
+int main() {
+
+ int readings[3] = {0, 0, 0};
+
+ pc.printf("Starting ADXL345 test...\n");
+ pc.printf("Device ID is: 0x%02x\n", accelerometer.getDevId());
+
+ //Go into standby mode to configure the device.
+ accelerometer.setPowerControl(0x00);
+
+ //Full resolution, +/-16g, 4mg/LSB.
+ accelerometer.setDataFormatControl(0x0B);
+
+ //3.2kHz data rate.
+ accelerometer.setDataRate(ADXL345_3200HZ);
+
+ //Measurement mode.
+ accelerometer.setPowerControl(0x08);
+
+ while (1) {
+
+ wait(0.1);
+
+ accelerometer.getOutput(readings);
+
+ //13-bit, sign extended values.
+ pc.printf("%i, %i, %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]);
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Aug 03 08:31:00 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da
