Week of 4/27
- euanr723
- May 1
- 2 min read
This week, I spent the vast bulk of my time working on finalizing the finishing the basic control for my rover project. This started off by me first scrapping the old code that I had been using. The reason for this was as first, I was using one joystick to control the entire project. After trying multiple variations of different types of code, I decided to find another joy stick instead for use. After making this switch, the coding became far more friendly, I first started by breaking it into two sperate variables, allowing each joystick to control a specific side of the rover, this would allow the user to adjust the speeds of either as a means to control it.

After this first step was complete, I next moved on to testing and debugging my code. This involved many different adjustments and tweaks with certain variables or issues with the logic. On top of this, I next had to next, worry about fixing the motor driver, which was not working properly. After finding another of the same motor driver, I ran through various diagnostic tests with the motor to ensure that it would work as intended. After deciding to use it I set it up with the new code.



At first, the controls where slightly shaky, with some aspects of it not working properly. However, after tweaking certain sections of the code I was able to get the whole control system working. After this I spent the final part of my week to begin researching more about the design for the rover. For the first prototype, my main concern it simply getting it working completely before moving on to more complex and important changes in the overall design.
y2 = analogRead(Y2pin);
y = analogRead(Ypin);
y = map(y, 0, 1023, 0, 255);
y2 = map(y2, 0, 1023, 0, 255);
int yrev = 255 - y;
if (y < 120) {
analogWrite(5, 255 - y); // Backward (using yrev for reverse)
digitalWrite(6, LOW);
Serial.print("L:");
Serial.println(y);
} else if (y > 130) {
analogWrite(6, y); // Forward
digitalWrite(5, LOW);
Serial.print("H:");
Serial.println(y);
} else { // Dead zone (stop motor)
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
if (y2 < 120) {
analogWrite(9, 255 - y2);
digitalWrite(10, LOW);
Serial.println(y2);
} else if (y2 > 130) {
analogWrite(10, y2);
digitalWrite(9, LOW);
Serial.print("H:");
Serial.println(y2);
} else { // Dead zone (stop motor)
digitalWrite(9, LOW);
digitalWrite(10, LOW);
}
}



Comments