This commit is contained in:
Lucas Marais 2023-03-31 09:47:56 +02:00
parent 7292715015
commit 3c0b12d1c4
2 changed files with 44 additions and 3 deletions

23
gyro/gyro.ino Normal file
View File

@ -0,0 +1,23 @@
#include"MeMCore.h"
#include <Wire.h>
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);
}

View File

@ -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()<minDistance){
motor1.run(100);
motor2.run(100);
delay(800);
}
else {
motor1.run(-155);
motor2.run(155);
}
}