wireless dc motor control

hi i have a problem with controlling my dc motor with a windows phone. i can send input from the phone through Wi-Fi to the arduino and make the motor rotate with the input. but the problem is that i want to stop it with strop button on the phone. i have a delay for the dc motor for 1000ms. so the motor is coming to stop after the 1000ms only but i want stop to it anytime the user press the stop button? how can i achieve this? Thank you. any help would be greatly appreciated. :slight_smile:

As you haven't posted any of your code it's a bit hard to give any advice.

How soon after you press the button on the phone (measured in millisecs) do you want the motor to stop?

...R

What is the latency in starting the motion? Is it the same as for stopping?

my code is simple. i am reading from serial input and using the inputs i am giving voltage to the pins. there i put a delay of 10 seconds using delay(10000);.

i am guessing the program is waiting for the delay to to be over before going to next line of the program. i want to be able to stop the motor in between the 10 seconds its running when the stop button is pressed.

char input = readserialinput();

if (input == "a"){
digitalWrite (motorpin, HIGH);
delay(10000); }
else if (input == "b")
digitalWrite (motorpin, LOW);

You need to replace your use of the delay() function with the technique in the Blink Without Delay example sketch. A longer demo of the technique is in the first post of this Thread.

The delay() function paralyses the Arduino until the time has elapsed.

...R