Revision 2fa9c672
examples/bunny/bunny.ino | ||
---|---|---|
5 | 5 |
|
6 | 6 |
/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor), |
7 | 7 |
which provides a common 'type' for sensor data and some helper functions. |
8 |
|
|
8 |
|
|
9 | 9 |
To use this driver you will also need to download the Adafruit_Sensor |
10 | 10 |
library and include it in your libraries folder. |
11 | 11 |
|
... | ... | |
14 | 14 |
sensor in any data logs, etc. To assign a unique ID, simply |
15 | 15 |
provide an appropriate value in the constructor below (12345 |
16 | 16 |
is used by default in this example). |
17 |
|
|
17 |
|
|
18 | 18 |
Connections |
19 | 19 |
=========== |
20 | 20 |
Connect SCL to analog 5 |
21 | 21 |
Connect SDA to analog 4 |
22 | 22 |
Connect VDD to 3.3-5V DC |
23 | 23 |
Connect GROUND to common ground |
24 |
|
|
24 |
|
|
25 | 25 |
History |
26 | 26 |
======= |
27 | 27 |
2015/MAR/03 - First release (KTOWN) |
... | ... | |
48 | 48 |
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); |
49 | 49 |
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" xxx"); |
50 | 50 |
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" xxx"); |
51 |
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" xxx");
|
|
51 |
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" xxx"); |
|
52 | 52 |
Serial.println("------------------------------------"); |
53 | 53 |
Serial.println(""); |
54 | 54 |
delay(500); |
... | ... | |
59 | 59 |
Arduino setup function (automatically called at startup) |
60 | 60 |
*/ |
61 | 61 |
/**************************************************************************/ |
62 |
void setup(void)
|
|
62 |
void setup(void) |
|
63 | 63 |
{ |
64 | 64 |
Serial.begin(115200); |
65 | 65 |
Serial.println("Orientation Sensor Test"); Serial.println(""); |
66 |
|
|
66 |
|
|
67 | 67 |
/* Initialise the sensor */ |
68 | 68 |
if(!bno.begin()) |
69 | 69 |
{ |
... | ... | |
71 | 71 |
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!"); |
72 | 72 |
while(1); |
73 | 73 |
} |
74 |
|
|
74 |
|
|
75 | 75 |
delay(1000); |
76 |
|
|
76 |
|
|
77 | 77 |
/* Display some basic information on this sensor */ |
78 | 78 |
displaySensorDetails(); |
79 | 79 |
} |
... | ... | |
84 | 84 |
should go here) |
85 | 85 |
*/ |
86 | 86 |
/**************************************************************************/ |
87 |
void loop(void)
|
|
87 |
void loop(void) |
|
88 | 88 |
{ |
89 |
/* Get a new sensor event */
|
|
90 |
sensors_event_t event;
|
|
89 |
/* Get a new sensor event */ |
|
90 |
sensors_event_t event; |
|
91 | 91 |
bno.getEvent(&event); |
92 |
|
|
92 |
|
|
93 | 93 |
/* Board layout: |
94 | 94 |
+----------+ |
95 | 95 |
| *| RST PITCH ROLL HEADING |
96 | 96 |
ADR |* *| SCL |
97 | 97 |
INT |* *| SDA ^ /-> |
98 |
PS1 |* *| GND | |
|
|
98 |
PS1 |* *| GND | | |
|
99 | 99 |
PS0 |* *| 3VO Y Z--> \-X |
100 |
| *| VIN
|
|
100 |
| *| VIN |
|
101 | 101 |
+----------+ |
102 | 102 |
*/ |
103 | 103 |
|
... | ... | |
110 | 110 |
Serial.print((float)event.orientation.z); |
111 | 111 |
Serial.println(F("")); |
112 | 112 |
|
113 |
/* Also send calibration data for each sensor. */ |
|
114 |
uint8_t sys, gyro, accel, mag = 0; |
|
115 |
bno.getCalibration(&sys, &gyro, &accel, &mag); |
|
116 |
Serial.print(F("Calibration: ")); |
|
117 |
Serial.print(sys, DEC); |
|
118 |
Serial.print(F(" ")); |
|
119 |
Serial.print(gyro, DEC); |
|
120 |
Serial.print(F(" ")); |
|
121 |
Serial.print(accel, DEC); |
|
122 |
Serial.print(F(" ")); |
|
123 |
Serial.println(mag, DEC); |
|
124 |
|
|
113 | 125 |
delay(BNO055_SAMPLERATE_DELAY_MS); |
114 |
} |
|
126 |
} |
examples/bunny/processing/cuberotate/cuberotate.pde | ||
---|---|---|
15 | 15 |
|
16 | 16 |
// Serial port state. |
17 | 17 |
Serial port; |
18 |
String buffer = ""; |
|
19 | 18 |
final String serialConfigFile = "serialconfig.txt"; |
20 | 19 |
boolean printSerial = false; |
21 | 20 |
|
... | ... | |
23 | 22 |
GPanel configPanel; |
24 | 23 |
GDropList serialList; |
25 | 24 |
GLabel serialLabel; |
25 |
GLabel calLabel; |
|
26 | 26 |
GCheckbox printSerialCheckbox; |
27 | 27 |
|
28 | 28 |
void setup() |
29 | 29 |
{ |
30 |
size(400, 550, OPENGL);
|
|
30 |
size(640, 480, OPENGL);
|
|
31 | 31 |
frameRate(30); |
32 | 32 |
model = new OBJModel(this); |
33 | 33 |
model.load("bunny.obj"); |
... | ... | |
58 | 58 |
serialList = new GDropList(this, 90, 20, 200, 200, 6); |
59 | 59 |
serialList.setItems(availablePorts, selectedPort); |
60 | 60 |
configPanel.addControl(serialList); |
61 |
calLabel = new GLabel(this, 300, 20, 350, 25, "Calibration: Sys=? Gyro=? Accel=? Mag=?"); |
|
62 |
configPanel.addControl(calLabel); |
|
61 | 63 |
printSerialCheckbox = new GCheckbox(this, 5, 50, 200, 20, "Print serial data"); |
62 | 64 |
printSerialCheckbox.setSelected(printSerial); |
63 | 65 |
configPanel.addControl(printSerialCheckbox); |
... | ... | |
78 | 80 |
pointLight(200, 200, 255, -400, 400, 500); |
79 | 81 |
pointLight(255, 255, 255, 0, 0, -500); |
80 | 82 |
|
81 |
// Displace objects from 0,0
|
|
82 |
translate(200, 300, 0);
|
|
83 |
// Move bunny from 0,0 in upper left corner to roughly center of screen.
|
|
84 |
translate(300, 380, 0);
|
|
83 | 85 |
|
84 | 86 |
// Rotate shapes around the X/Y/Z axis (values in radians, 0..Pi*2) |
85 | 87 |
rotateZ(radians(roll)); |
... | ... | |
109 | 111 |
roll = float(list[3]); // Roll = Z |
110 | 112 |
pitch = float(list[2]); // Pitch = Y |
111 | 113 |
yaw = float(list[1]); // Yaw/Heading = X |
112 |
buffer = incoming; |
|
113 | 114 |
} |
114 | 115 |
if ( (list.length > 0) && (list[0].equals("Alt:")) ) |
115 | 116 |
{ |
116 | 117 |
alt = float(list[1]); |
117 |
buffer = incoming; |
|
118 | 118 |
} |
119 | 119 |
if ( (list.length > 0) && (list[0].equals("Temp:")) ) |
120 | 120 |
{ |
121 | 121 |
temp = float(list[1]); |
122 |
buffer = incoming; |
|
122 |
} |
|
123 |
if ( (list.length > 0) && (list[0].equals("Calibration:")) ) |
|
124 |
{ |
|
125 |
int sysCal = int(list[1]); |
|
126 |
int gyroCal = int(list[2]); |
|
127 |
int accelCal = int(list[3]); |
|
128 |
int magCal = int(list[4]); |
|
129 |
calLabel.setText("Calibration: Sys=" + sysCal + " Gyro=" + gyroCal + " Accel=" + accelCal + " Mag=" + magCal); |
|
123 | 130 |
} |
124 | 131 |
} |
125 | 132 |
} |
... | ... | |
161 | 168 |
if (checkbox == printSerialCheckbox) { |
162 | 169 |
printSerial = printSerialCheckbox.isSelected(); |
163 | 170 |
} |
164 |
} |
|
171 |
} |
Also available in: Unified diff