I am very new at this and I might be biting on more than I can chew on.

This is my project.

In control line we use "timers" to start and shut down the motor. In addition to that we use some kind of gyro accelerometer to achieve a throttle control so when we go up the motor rpm increase and vice versa and perhaps other functions like retractable gear maybe LEDs whatever. So the timer is not exactly just a timer.

I want to do 3 things with Arduino.

1 keep track of time and sequence events (FE start timer at beginning, delay the motor at some time stop the motor at end the flight time after some time, maybe get a visual warming before and after the motor starts or stops).
At this time do this kind of thing.
2 throttle control to desired speed
3 some LED feedback. (this is the only part I know how to do).

LED are easy
For throttle I am thinking this:

va=velocity actual (from sensor and I know how to retrieve the data from the sensor)
Vd=velocity desired
Tmin=throttle minim
Tmax=throttle maximum

I am thinking to use for loop to bring the desired speed within 1% of the desired speed (Va>=1.01Va && Va<=.99Va). If the error is negative then the model overspends and the throttle will be lowered by G((Vd-Va)+O). The higher the error(Vd-Va), the more correction the throttle will apply.

for (Tmin; Va>=1.01Va && Va<=.99Va; T=T+G((Vd-Va)+O));
if T<Tmin; {T=Tmin};
if T>Tmax; {T=Tmax};

Is this going to work?


1 How do you do timed events?
2 If the processor is inside the "for loop" and parks there for a while what happens to the rest of the stuff? (say you do simultaneously a LED blink at some interval, or some other task like report temperature every 10 seconds). From what I understand the loop will continue till the conditions are met and only then the process moves on to the next line of code?

Thanks for pointing me in the right direction gentleman.

This is my project.

You just left the title but forgot the section that describes what your project is.

Go here Useful links - check here for reference posts / tutorials - Programming Questions - Arduino Forum

and read the stuff under "General Design". Both of your questions will be answered.

In brief:

  1. There's a function that meaasures time in milliseconds and one that measures in microseconds. Use them.

  2. Don't use long for loops that do physical things. Let the loop function be the thing that is doing the looping. Use if statements to control what runs when.