Multiple Statements to a Loop

You can imagine analogWrite as switching on with different intensity.

analogWrite(vm,255) : output "Full power"

analogWrite(vm,127) : output "half power"

analogWrite(vm,63) : output "25% power"

analogWrite(vm,0) : output "0% power" which is equivalent to switch off

So making your motor vibrate in a pattern similar to

  1. vibrate for 2 seconds
  2. stop for 3 seconds
  3. vibrate for 5 seconds
  4. stop for 1 second

would be

analogWrite(vm,255); // vibrate
delay(2000);
analogWrite(vm,0); // stop
delay(3000);
analogWrite(vm,255); // vibrate
delay(5000);
analogWrite(vm,0); // stop
delay(1000);

If you want to do something in parallel to the vibration-pattern you can not use delay()
because delay() is blocking.

Then you need non-blocking timing

digitalWrite(vm,HIGH) ; // output 100% power
digitalWrite(vm,LOW) ; // output 0% power = zero power

EDIT: the explanation inside of the standard blink without delay provided by the Arduino-Website is

really poor

I really would like to see the Arduino-Website team to improve this example to make it easy to understand. The reason is: it does not explain the basic principle on an everyday analogon.

As long as this hasn't happend I recommend reading this explanation instead:

best regards Stefan