mirror of
https://github.com/supleed2/ELEC50003-P1-CW.git
synced 2024-12-22 21:45:49 +00:00
IMU Stuff
This commit is contained in:
parent
cc113aa086
commit
c6f93039a1
|
@ -484,7 +484,6 @@ void loop()
|
||||||
if (!initialAngleSet)
|
if (!initialAngleSet)
|
||||||
{
|
{
|
||||||
//turn to angle
|
//turn to angle
|
||||||
currentHeading = getCurrentHeading();
|
|
||||||
if (currentHeading < requiredHeading)
|
if (currentHeading < requiredHeading)
|
||||||
{ //turn right
|
{ //turn right
|
||||||
Serial.println("turning right");
|
Serial.println("turning right");
|
||||||
|
@ -647,12 +646,12 @@ void loop()
|
||||||
total_x = 10 * total_x1 / 157; //Conversion from counts per inch to mm (400 counts per inch)
|
total_x = 10 * total_x1 / 157; //Conversion from counts per inch to mm (400 counts per inch)
|
||||||
total_y = 10 * total_y1 / 157; //Conversion from counts per inch to mm (400 counts per inch)
|
total_y = 10 * total_y1 / 157; //Conversion from counts per inch to mm (400 counts per inch)
|
||||||
|
|
||||||
Serial.print('\n');
|
/* Serial.print('\n');
|
||||||
|
|
||||||
Serial.println("Distance_x = " + String(total_x));
|
Serial.println("Distance_x = " + String(total_x));
|
||||||
|
|
||||||
Serial.println("Distance_y = " + String(total_y));
|
Serial.println("Distance_y = " + String(total_y));
|
||||||
Serial.print('\n');
|
Serial.print('\n'); */
|
||||||
//-------------------------------------------------------SMPS & MOTOR CODE START------------------------------------------------------//
|
//-------------------------------------------------------SMPS & MOTOR CODE START------------------------------------------------------//
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
if (loopTrigger)
|
if (loopTrigger)
|
||||||
|
|
|
@ -15,4 +15,7 @@ framework = arduino
|
||||||
lib_deps =
|
lib_deps =
|
||||||
tanakamasayuki/I2C MPU6886 IMU@^1.0.0
|
tanakamasayuki/I2C MPU6886 IMU@^1.0.0
|
||||||
m5stack/M5StickC@^0.2.0
|
m5stack/M5StickC@^0.2.0
|
||||||
|
bblanchon/ArduinoJson@^6.18.0
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
monitor_port = COM8
|
||||||
|
upload_port = COM8
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <M5StickC.h>
|
#include <M5StickC.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
float pitch, roll, yaw;
|
float pitch, roll, yaw;
|
||||||
|
|
||||||
|
@ -7,13 +8,18 @@ void setup() {
|
||||||
M5.begin();
|
M5.begin();
|
||||||
M5.IMU.Init();
|
M5.IMU.Init();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial1.begin(115200, SERIAL_8N1, 26, 0);
|
Serial1.begin(9600, SERIAL_8N1, 26, 0);
|
||||||
}
|
}
|
||||||
void loop() {
|
void loop() {
|
||||||
M5.IMU.getAhrsData(&pitch, &roll, &yaw);
|
M5.IMU.getAhrsData(&pitch, &roll, &yaw);
|
||||||
M5.Lcd.setCursor(0, 45);
|
M5.Lcd.setCursor(0, 45);
|
||||||
M5.Lcd.printf("%5.2f\n", roll);
|
M5.Lcd.printf("%5.2f\n", roll);
|
||||||
Serial.printf("{\"cH\":%5.2f}\n", roll);
|
// Serial.printf("{\"cH\":%5.2f}\n", roll);
|
||||||
Serial1.printf("{\"cH\":%5.2f}\n", roll);
|
// Serial1.printf("{\"cH\":%5.2f}\n", roll);
|
||||||
|
DynamicJsonDocument tdoc(1024);
|
||||||
|
tdoc["cH"] = roll;
|
||||||
|
serializeJson(tdoc, Serial1);
|
||||||
|
|
||||||
|
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
Loading…
Reference in a new issue