About Dc Motor Pause,Continue and Motor's Running time.

I am a beginner. On the issue of the DC motor. My questions is:
If the DC motor is a total rotation of 10 seconds, Can I use interrupts to control the DC motor during running ,For example:When press a key to pause the Dc Motor,and Press the key agin to continue. I hope that the motor total rotation time is : 10 seconds. How to do this ?
I drive the Dc Motor using the L298P chip. Please expert advice. Thanks.

I'm struggling to understand the requirement, but if it's to control a motor with a switch and give a maximum total run time of ten seconds, I don't see a need for interrupts. Just loop looking for button presses, debounce them and turn the motor on or off. Keep track of how long the motor has been running using millis. When it reaches ten seconds, stop the motor and ignore the switch.

This is a sample program:

// # Editor : Lauren from DFRobot
// # Date : 17.02.2012

// # Product name: L298P Motor Shield
// # Product SKU : DRI0009
// # Version : 1.0

// # Description:
// # The sketch for using the L298N motor shield

// # Connection:
// # Directly connect the Motor shield to the Arduino controller
// #
// #

int E1 = 6;
int M1 = 7;
//int E2 = 5;
//int M2 = 4;
int readpin=3;
void setup()
{
pinMode(M1, OUTPUT);
pinMode(readpin,INPUT);
//pinMode(M2, OUTPUT);
}

void loop()
{
//int value;
//for(value = 0 ; value <= 255; value+=5)
{
digitalWrite(M1,HIGH);
analogWrite(E1, 100); //PWM Speed Control
delay(5000);
digitalWrite(M1,LOW);
analogWrite(E1, 100); //PWM Speed Control
delay(3000);
}
}

The motor is run 5 seconds, and reverse 5 seconds. Is Right?
But I want pause the motor in the middle of the 5 seconds. The Pause use a button key.
The Programer 's test results, the motor will be not stop.
How to do ? :roll_eyes:

Get rid of the calls to "delay" and use the technique introduced in the "blink without delay" example.

Your proposal is to allow the motor to rotate time use WITHOUTDELAY methods.So, the key I imagine you should use interrupt, and then save the current time value and the corresponding operation. Is not it?

No, I certainly would not use interrupts, there is no need that I can see.
But you need to get rid of delays.
See the blink without delay example, without delay.