Loop() and how to delay loop without using delay().

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.

Read Serial Input Basics

And next time, use [ code ] tags. The forum software will eat some of your code if you don't.

I haven't even gotten to the point of flying it. I'm currently wondering on how to not use the delay method.

MorganS:
3 seconds is a long time for a drone. You can crash a long way in that time.

I'll check the link you sent.

The blink without delay example shows how to do something some amount of time after doing something else, without using delay().

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.

...R

Okay, I think I get the idea. Do you know of any major threads on autonomous drone building?

Google probably does.

...R

There are whole EdX courses on autonomous robotics. Worth considering in concert with exploring online
forums on robotics.

Robin2:
Google probably does.

...R

Thanks.. yeah Google is a bit more proactive. I guess I need to understand gyroscope, accelerometer, and IMU's a bit more. Thank's guys!

Google is a bit more proactive.

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...