Skip to content
Snippets Groups Projects
Commit 8023e0d2 authored by mhby1g21's avatar mhby1g21
Browse files

fixed directions

parent e8749b7f
No related branches found
No related tags found
No related merge requests found
......@@ -186,10 +186,10 @@ void loop() {
// Move Forward - Using the exact structure from Medical_V2.ino
void moveForward() {
// Set direction pins first
digitalWrite(IN2, HIGH);
digitalWrite(IN1, LOW);
digitalWrite(IN4, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN1, HIGH);
digitalWrite(IN4, LOW);
digitalWrite(IN3, HIGH);
Direction = 1;
// Then apply IMU control if available
......@@ -205,10 +205,10 @@ void moveForward() {
// Move Backwards - Using the exact structure from Medical_V2.ino
void moveBackward() {
// Set direction pins first
digitalWrite(IN2, LOW);
digitalWrite(IN1, HIGH);
digitalWrite(IN4, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN2, HIGH);
digitalWrite(IN1, LOW);
digitalWrite(IN4, HIGH);
digitalWrite(IN3, LOW);
Direction = -1;
// Then apply IMU control if available
......@@ -217,36 +217,34 @@ void moveBackward() {
} else {
// Without IMU, just use basic speed control
analogWrite(ENA, SPEED);
analogWrite(ENB, SPEED);
analogWrite(ENB, SPEED);
}
}
// Turn Left - Using the exact structure from Medical_V2.ino
void turnLeft() {
digitalWrite(IN2, HIGH);
// Turn Right - Using the exact structure from Medical_V2.ino
void turnRight() {
digitalWrite(IN2, LOW); // Left motor stopped
digitalWrite(IN1, LOW);
digitalWrite(IN4, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW); // Right motor forward (per reversed convention)
digitalWrite(IN3, HIGH);
Direction = 0;
// No IMU control for turning
analogWrite(ENA, SPEED);
analogWrite(ENB, 0);
analogWrite(ENA, 0); // Left motor stopped
analogWrite(ENB, SPEED); // Right motor active
}
// Turn Right - Using the exact structure from Medical_V2.ino
void turnRight() {
digitalWrite(IN2, LOW);
digitalWrite(IN1, LOW);
digitalWrite(IN4, HIGH);
// Turn Left - Using the exact structure from Medical_V2.ino
void turnLeft(IN2, LOW); // Left motor forward (per reversed convention)
digitalWrite(IN1, HIGH);
digitalWrite(IN4, LOW); // Right motor stopped
digitalWrite(IN3, LOW);
Direction = 0;
// No IMU control for turning
analogWrite(ENA, 0);
analogWrite(ENB, SPEED);
analogWrite(ENA, SPEED); // Left motor active
analogWrite(ENB, 0); // Right motor stopped
}
// Using the exact IMU_Control from Medical_V2.ino
void IMU_Control() {
// Update IMU data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment