Skip to content

Instantly share code, notes, and snippets.

@woodif
Last active March 16, 2024 11:15
Show Gist options
  • Save woodif/e95e71727fa263b646f3fc36b29819bf to your computer and use it in GitHub Desktop.
Save woodif/e95e71727fa263b646f3fc36b29819bf to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
Adafruit_BNO055 bno = Adafruit_BNO055(55,0x29);
void setup(void)
{
Serial.begin(9600);
Serial.println("Orientation Sensor Test"); Serial.println("");
// Wire.begin(22,27); // SDA pin 21, SCL pin 22
/* Initialise the sensor */
if(!bno.begin())
{
/* There was a problem detecting the BNO055 ... check your connections */
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while(1);
}
delay(1000);
bno.setExtCrystalUse(true);
}
void loop(void)
{
/* Get a new sensor event */
sensors_event_t event;
bno.getEvent(&event);
/* Display the floating point data */
Serial.print("X: ");
Serial.print(event.orientation.x, 4);
Serial.print("\tY: ");
Serial.print(event.orientation.y, 4);
Serial.print("\tZ: ");
Serial.print(event.orientation.z, 4);
Serial.println("");
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment