Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FXOS8700 Hexi_OLED_SSD1351
Fork of Hexi_Accelero_Magneto_Example by
main.cpp
- Committer:
- maclobdell
- Date:
- 2016-08-13
- Revision:
- 1:6da908234299
- Parent:
- 0:207337d58f96
- Child:
- 2:f9c24c129575
File content as of revision 1:6da908234299:
#include "mbed.h"
#include "FXOS8700CQ.h"
/* Check out the full featured example application for interfacing to the
* Accelerometer/Magnetometer device at the following URL
* https://developer.mbed.org/users/trm/code/fxos8700cq_example/
*/
DigitalOut led1(LED1);
// Pin connections & address for Hexiwear
FXOS8700CQ fxos(PTC11, PTC10, FXOS8700CQ_SLAVE_ADDR0); // SDA, SCL, (addr << 1)
// Storage for the data from the sensor
SRAWDATA accel_data;
SRAWDATA magn_data;
// main() runs in its own thread in the OS
// (note the calls to Thread::wait below for delays)
int main() {
fxos.enable();
while (true) {
led1 = !led1;
// Example data printing
fxos.get_data(&accel_data, &magn_data);
printf("A X:%5d,Y:%5d,Z:%5d M X:%5d,Y:%5d,Z:%5d\r\n",
accel_data.x, accel_data.y, accel_data.z,
magn_data.x, magn_data.y, magn_data.z);
Thread::wait(500);
}
}
