void loop() {
// Wait for some input
if(Serial.available() > 0) {
currServo = normalizeThrottle(Serial.parseInt());
Serial.println("Current Servo is: " + String(currServo));
Serial.println("Set throttle");
delay(3000);
// Read the new throttle value
int throttle = normalizeThrottle( Serial.parseInt() );
// Print it out
Serial.print("Setting throttle to: ");
Serial.println(throttle);
// Change throttle to the new value
changeThrottle(throttle);
Serial.println("Enter 0,1,2,3 to choose a servo, or 4 for all Servo's to run");
}
}
Basically I'm trying to enter two different inputs through the serial monitor. This isn't highly practical for drones I think. But for now I want to understand a little bit more on how to program arduino. Also I'm using this to test out the motors as I think I damaged them from another build I did with the Naze32 board. In order to first select the servo I want to use, and then set the throttle for that servo. I am using a delay. I was wondering if there is another way of doing this. So I don't have to rush to type in the throttle. Not that 3 seconds isn't a long time. Thank you community!
3 seconds is a long time for a drone. You can crash a long way in that time.
Also remember that Serial.parseInt() can also wait up to a second for you to type in a number. You can crash even further in that time.
The important thing to remember about Serial is that it is S L O W. Your Arduino can do thousands of instructions in the time it takes for a single character to arrive, even at high serial data rates.
The demo Several Things at a Time is an extended example of BWoD and illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.
I've never found that to be the case. Mr. Google is the laziest person I know. Doesn't do a damned thing until I ASK for information... Doesn't try to guess what I really want...