mirror of
https://gitlab.waag.org/make/fablab/interns/2025/sam.git
synced 2025-08-04 04:14:56 +00:00
finaly fix hopefully
This commit is contained in:
@@ -7,20 +7,21 @@
|
|||||||
First used the wrong library I used the adafruit bno0xx library instead of the sparkfun bno08x library
|
First used the wrong library I used the adafruit bno0xx library instead of the sparkfun bno08x library
|
||||||
|
|
||||||
??? failure
|
??? failure
|
||||||
```cpp
|
|
||||||
#include "conf.h"
|
|
||||||
#include <Adafruit_BNO08x.h>
|
|
||||||
#include <sh2.h>
|
|
||||||
#include <sh2_SensorValue.h>
|
|
||||||
#include <sh2_err.h>
|
|
||||||
#include <sh2_hal.h>
|
|
||||||
#include <sh2_util.h>
|
|
||||||
#include <shtp.h>
|
|
||||||
|
|
||||||
Adafruit_BNO08x bno08x(BNOINTERRUPTSIG);
|
```cpp
|
||||||
sh2_SensorValue_t sensorValue;
|
#include "conf.h"
|
||||||
|
#include <Adafruit_BNO08x.h>
|
||||||
|
#include <sh2.h>
|
||||||
|
#include <sh2_SensorValue.h>
|
||||||
|
#include <sh2_err.h>
|
||||||
|
#include <sh2_hal.h>
|
||||||
|
#include <sh2_util.h>
|
||||||
|
#include <shtp.h>
|
||||||
|
|
||||||
void setup() {
|
Adafruit_BNO08x bno08x(BNOINTERRUPTSIG);
|
||||||
|
sh2_SensorValue_t sensorValue;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("setup started");
|
Serial.println("setup started");
|
||||||
// Setup all ESC
|
// Setup all ESC
|
||||||
@@ -29,9 +30,9 @@ void setup() {
|
|||||||
// ledcAttach(MOTOR3, PWMFREQ, PWMRESOLUTION);
|
// ledcAttach(MOTOR3, PWMFREQ, PWMRESOLUTION);
|
||||||
// ledcAttach(MOTOR4, PWMFREQ, PWMRESOLUTION);
|
// ledcAttach(MOTOR4, PWMFREQ, PWMRESOLUTION);
|
||||||
Serial.print("Setup Started");
|
Serial.print("Setup Started");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
// put your main code here, to run repeatedly:
|
||||||
sleep(3)
|
sleep(3)
|
||||||
if (!bno08x.begin_I2C()) {
|
if (!bno08x.begin_I2C()) {
|
||||||
@@ -48,21 +49,22 @@ void loop() {
|
|||||||
Serial.print(sensorValue.un.gameRotationVector.j);
|
Serial.print(sensorValue.un.gameRotationVector.j);
|
||||||
Serial.print(" k: ");
|
Serial.print(" k: ");
|
||||||
Serial.println(sensorValue.un.gameRotationVector.k);
|
Serial.println(sensorValue.un.gameRotationVector.k);
|
||||||
}
|
}
|
||||||
|
|
||||||
//https://randomnerdtutorials.com/esp32-pwm-arduino-ide/
|
//https://randomnerdtutorials.com/esp32-pwm-arduino-ide/
|
||||||
//https://github.com/adafruit/Adafruit_BNO08x/blob/master/examples/rotation_vector/rotation_vector.ino#L25
|
//https://github.com/adafruit/Adafruit_BNO08x/blob/master/examples/rotation_vector/rotation_vector.ino#L25
|
||||||
```
|
```
|
||||||
|
|
||||||
??? example
|
??? example
|
||||||
```cpp
|
|
||||||
#include <SparkFun_BNO080_Arduino_Library.h>
|
|
||||||
#include <Wire.h>
|
|
||||||
#include "conf.h"
|
|
||||||
|
|
||||||
BNO080 myIMU;
|
```cpp
|
||||||
|
#include <SparkFun_BNO080_Arduino_Library.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
void setup() {
|
BNO080 myIMU;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("setup started");
|
Serial.println("setup started");
|
||||||
// Setup all ESC
|
// Setup all ESC
|
||||||
@@ -76,10 +78,10 @@ void setup() {
|
|||||||
myIMU.begin();
|
myIMU.begin();
|
||||||
Wire.setClock(400000); //Increase I2C data rate to 400kHz
|
Wire.setClock(400000); //Increase I2C data rate to 400kHz
|
||||||
myIMU.enableRotationVector(50); //Send data update every 50ms}
|
myIMU.enableRotationVector(50); //Send data update every 50ms}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
if (myIMU.dataAvailable() == true) {
|
if (myIMU.dataAvailable() == true) {
|
||||||
float roll = (myIMU.getRoll()) * 180.0 / PI; // Convert roll to degrees
|
float roll = (myIMU.getRoll()) * 180.0 / PI; // Convert roll to degrees
|
||||||
@@ -94,15 +96,15 @@ void loop() {
|
|||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void calibrateESC() {
|
void calibrateESC() {
|
||||||
ledcWrite(MOTOR1, 1100);
|
ledcWrite(MOTOR1, 1100);
|
||||||
ledcWrite(MOTOR2, 1100);
|
ledcWrite(MOTOR2, 1100);
|
||||||
ledcWrite(MOTOR3, 1100);
|
ledcWrite(MOTOR3, 1100);
|
||||||
ledcWrite(MOTOR4, 1100);
|
ledcWrite(MOTOR4, 1100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//https://randomnerdtutorials.com/esp32-pwm-arduino-ide/
|
//https://randomnerdtutorials.com/esp32-pwm-arduino-ide/
|
||||||
//https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/blob/main/examples/Example24-UncalibratedGyro/Example24-UncalibratedGyro.ino
|
//https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/blob/main/examples/Example24-UncalibratedGyro/Example24-UncalibratedGyro.ino
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user