-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from KadenKing/Vision
Vision
- Loading branch information
Showing
4 changed files
with
88 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <Wire.h> | ||
#include <Adafruit_Sensor.h> | ||
#include <Adafruit_BNO055.h> | ||
#include <utility/imumaths.h> | ||
#include <math.h> | ||
|
||
|
||
/* This driver reads raw data from the BNO055 | ||
Connections | ||
=========== | ||
Connect SCL to analog 5 | ||
Connect SDA to analog 4 | ||
Connect VDD to 3.3V DC | ||
Connect GROUND to common ground | ||
History | ||
======= | ||
2015/MAR/03 - First release (KTOWN) | ||
*/ | ||
|
||
/* Set the delay between fresh samples. Wait for serial input to define sample rate. */ | ||
|
||
|
||
Adafruit_BNO055 bno = Adafruit_BNO055(); | ||
|
||
|
||
void setup(void){ | ||
while(!Serial.available()){ | ||
#define BNO055_SAMPLERATE_DELAY_MS (Serial.read()) | ||
} | ||
//remove the above serial read after testing and timing diagram is established. | ||
Serial.begin(9600); | ||
|
||
/* Initialise the sensor */ | ||
|
||
if(!bno.begin()) | ||
{ | ||
/* There was a problem detecting the BNO055 ... check your connections */ | ||
Serial.println("ConnectionFail"); | ||
while(1); | ||
} | ||
|
||
|
||
bno.setExtCrystalUse(false); | ||
|
||
Serial.println("Calibration status values: 0=uncalibrated, 3=fully calibrated"); | ||
|
||
} | ||
void loop(){ | ||
Serial.println(IMU_data()); | ||
} | ||
|
||
|
||
String IMU_data() | ||
{ | ||
String data; | ||
double angle; | ||
// Possible vector values can be: | ||
// - VECTOR_ACCELEROMETER - m/s^2 | ||
// - VECTOR_MAGNETOMETER - uT | ||
// - VECTOR_GYROSCOPE - rad/s | ||
// - VECTOR_EULER - degrees | ||
// - VECTOR_LINEARACCEL - m/s^2 | ||
// - VECTOR_GRAVITY - m/s^2 | ||
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER); | ||
angle = atan2(euler.y(),euler.x()); | ||
/* Display the floating point data */ | ||
data = "angle[ " + String(angle) + "] z[ " + String(euler.z()) + "]"; | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters