How to make 3 3.3V vibration motor vibrate at the same time but stop at any time

My project is 3 Infrared Distance Sensor and 3 vibration motor(small size vibration motor)

And the problem is the motor dont run at the same time but it run the first one and go to second, third..

I am using Arduino UNO R3
This is my code:

if(distance1 < 80)
{
digitalWrite(MotorF,HIGH);
delay(1000);
digitalWrite(MotorF,LOW);
delay(10);
}

if(distance2 < 80)
{
digitalWrite(MotorD, HIGH);
delay(1000);
digitalWrite(MotorD, LOW);
delay(10);

}

if(distance3 < 80)
{
digitalWrite(MotorL, HIGH);
delay(1000);
digitalWrite(MotorL, LOW);
delay(10);
}

if(distance4 < 80 )
{
digitalWrite(MotorR, HIGH);
delay(1000);
digitalWrite(MotorR, LOW);
delay(10);
}

For anything "at the same time" you need to use cooperative multitasking with millis() timing, instead of delay().
http://forum.arduino.cc/index.php?topic=223286.0

Take a look at the example BlinkWithoutDelay, it shows you how to eliminate the use of the delay() function completely. Once you've done that your motors may run together.

aarg:
For anything "at the same time" you need to use cooperative multitasking with millis() timing, instead of delay().
Demonstration code for several things at the same time - Project Guidance - Arduino Forum

Can I have an example code for this vibration motor? I have tried to understand this blinkwithoutdelay. But I dont understand it.

Maybe spend a little longer than half an hour on working it out and understanding it?

Hmmmm….. IR distance sensors and vibration in 3 dimensions. The imagination runs wild with what this project could be :smiling_imp: :stuck_out_tongue_closed_eyes: :grinning: :wink: :smiling_imp:

gfvalvo:
Hmmmm….. IR distance sensors and vibration in 3 dimensions. The imagination runs wild with what this project could be :smiling_imp: :stuck_out_tongue_closed_eyes: :grinning: :wink: :smiling_imp:

IR sensors is pretty bad idea. It have a lot of problem but it can detect fabric surface