please use the # button to apply proper code tags for your code
something like this ?
#include <Servo.h>
Servo myservo;
Servo myotherservo;
unsigned long start = 0;
bool flag = false;
void setup()
{
myservo.attach(9);
myotherservo.attach(10);
start = millis();
flag = false;
}
void loop()
{
myservo.write(120);
unsigned long now = millis();
if (now - start > 12500UL && flag == false)
{
flag = true; // do it only once
myotherservo.write(120);
}
}
This seems to be doing the exact same thing as the code I had. The servo, "myotherservo", turns on immediately. It does rotate again after 12.5 seconds, but the first rotation is what I need to NOT happen. I don't see why the code you gave me shouldn't work though. Of course, I am not familiar with the boolean constants true and false. I don't really get how they work. Also, it seems to me like (now - start) should always equal 0 since they are both assigned to millis(). Perhaps I am misunderstanding how millis() works? I am thinking that it keeps a constant count of how much time has elapsed and continuously stores it into the variable you've assigned to it (in this case start or now). This must be wrong though. I read the info on it on this website.
Thank you so much for your help!
The motor drives the robot forward in a straight line.
If it really does, your damned lucky, then.
It does drive in a straight line. It might not be
exactly straight, but it works well enough for our purposes. This robot uses a single motor drive, so it isn't as hard to keep straight as a differential drive system.