Problem while trying to run three things at a time

I am running a DC motor and Measuring its rpm using IR sensor.
Now i want to display the RPMs on tft using tft gauges.
for simplification when i press start button on tft it should start the motor ,Ir sensor and continuously display the RPMs.
Any way to do that??
I Can provide the code if i needed.
I am using timer1 and timer3 to call the gauge function and IR sensor while motor is running.

See Using millis() for timing. A beginners guide - Introductory Tutorials - Arduino Forum and Demonstration code for several things at the same time - Project Guidance - Arduino Forum

i am using millis() but for motor control i am using for loop and for loop cant be used in a non blocking code am i right??

So don't use a for loop. Let loop() do the looping so that it runs freely

Please post a full sketch showing the problem

 else if(Currentpage==6)
    motor_controll ();

in this when i am pressing start i am calling output and display which is the gauge and ir sensor too.

void  motor_controll ()
  //Ramp up
    if (v1[a]==0)
     analogWrite(R_PWM ,x); 

this is motor code.
I tried writing this code using millis(),but every thing got messed up because the time for motor ramp up must be decided by the user.

i want to ramp up the motor so that's why i am using for loop

full sketch is tooo lengthy.

When you want to ramp up the motor set a boolean to true and set the initial values such as start time and initial speed

Then in loop(), if the boolean is true call a motor control function that tests whether it is time to execute the next motor speed increase (using millis() of course) If it is time then do it. If the last step has been done then set the controlling boolean to false

i will try this and will post again.Thanku

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.