Skip to content
ejoerns edited this page Nov 6, 2013 · 2 revisions

Configurations

  • ACC_CONF_SENSITIVITY
  • ACC_CONF_DATA_RATE

Accelerometer example:

#include "sensors.h"
#include "dev/acc-sensor.h"

// get pointer to sensor
struct sensors_sensor *acc_sensor;
acc_sensor = sensors_find("Acc");

// activate
SENSORS_ACTIVATE(acc_sensor);

// configure
acc_sensor.configure(ACC_CONF_SENSITIVITY, ACC_2G);
acc_sensor.configure(ACC_CONF_DATA_RATE, ACC_100HZ;

// read and output values
printf("Acc x: %d, y: %d, z: %d\n",
    acc_sensor.value(ACC_X),
    acc_sensor.value(ACC_Y),
    acc_sensor.value(ACC_Z));

// deactivate
SENSORS_DEACTIVATE(acc_sensor);