From 3c0b12d1c4fbe41d64a7f725a84f1bf91547ffab Mon Sep 17 00:00:00 2001 From: Lucas Marais Date: Fri, 31 Mar 2023 09:47:56 +0200 Subject: [PATCH] Gyro --- gyro/gyro.ino | 23 +++++++++++++++++++++++ roomba/roomba.ino | 24 +++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 gyro/gyro.ino diff --git a/gyro/gyro.ino b/gyro/gyro.ino new file mode 100644 index 0000000..6cf1a07 --- /dev/null +++ b/gyro/gyro.ino @@ -0,0 +1,23 @@ +#include"MeMCore.h" +#include +MeGyro gyro; + +void setup() { + // put your setup code here, to run once: +Serial.begin(115200); + gyro.begin(); +} + +void loop() { + // put your main code here, to run repeatedly: + gyro.update(); + Serial.read(); + Serial.print("X:"); + Serial.print(gyro.getAngleX() ); + Serial.print(" Y:"); + Serial.print(gyro.getAngleY() ); + Serial.print(" Z:"); + Serial.println(gyro.getAngleZ() ); + Serial.println(gyro.getGyroY()); + delay(10); +} \ No newline at end of file diff --git a/roomba/roomba.ino b/roomba/roomba.ino index 95c2b6e..68703b3 100644 --- a/roomba/roomba.ino +++ b/roomba/roomba.ino @@ -1,9 +1,27 @@ -void setup() { - // put your setup code here, to run once: +#include "MeMCore.h" +MeDCMotor motor1(9); + +MeDCMotor motor2(10); + +MeUltrasonicSensor ultraSensor(PORT_3); + +int minDistance = 15; + +void setup() { + Serial.begin(9600); } void loop() { - // put your main code here, to run repeatedly: + + if (ultraSensor.distanceCm()