This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi im working on a school project and been stuck for a while. So i'm using whiskers as sensors and coded a program that works fine. However i must not use delay, for, while loops.
How can I replace the while function with something else that still works the code correctly?
void updateRobot_v(float vTarget_r, float vTarget_l, unsigned long duration) {
unsigned long startTime = currentTime;
while (currentTime - startTime < duration) {
if (currentTime - lastTime >= interval) {
motor_v(vTarget_r, vTarget_l);
lastTime = currentTime;
}
currentTime = millis();
 }
 // Stop the robot after the specified duration
motor_v(0, 0);
}
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/arduino/com...