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