Running a DC motor continuously using a PWm command while doing other tasks

I am trying to keep a DC motor running at a slow speed using a PWM command through analogwrite within loop and then trying to check time as well as checking a sound sensor. However a single just the analogwrite command does not keep the motor running. Is there a better way?

Please show your code (using [code] tags) and you will get the help you seek.

Here is what I think the relevant portion of the code. i am attempting to use the analogwrite command right now. But want to have the motor running continuously.

void loop() {
// put your main code here, to run repeatedly:
//this next command should keep the motor running continuously at slow speed
analogWrite(motorControl, motorPWMlevel);
////////////////////////////////////////////////////////////////////

servo1.detach();
///time measurement is taken
tmElements_t tm;
if (RTC.read™) {
Serial.print("Ok, Time = ");
// print2digits(tm.Hour);
//Serial.write(’:’);
//print2digits (tm.Minute);
//Serial.print(tm.Minute);
//RTC.read;
Serial.print(tm.Hour);
Serial.print(tm.Minute);
Serial.println();

if(tm.Minute == whentodraw) {
hourdraw();
}

}
unsigned long startMillis= millis(); // Start of sample window
unsigned int peakToPeak = 0; // peak-to-peak level

unsigned int signalMax = 0;
unsigned int signalMin = 1024;

// collect data for 50 mS
while (millis() - startMillis < sampleWindow)
{
sample = analogRead(0);
if (sample < 1024) // toss out spurious readings
{
if (sample > signalMax)
{
signalMax = sample; // save just the max levels
}
else if (sample < signalMin)
{
signalMin = sample; // save just the min levels
}
}
}
peakToPeak = signalMax - signalMin; // max - min = peak-peak amplitude
double volts = (peakToPeak * 5.0) / 1024; // convert to volts
Serial.println(volts);
servo1.attach(servoPin1);
if (volts > soundlevel) {
drawsound();
}
}

Hi, Welcome to the Forum Please post your [u]entire code[/u].

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :)

PWM provides a continuous signal, the motor will run until you stop it.

When you use the Servo library it takes over the Timer that is used to provide PWM on pins 9 and 10 on an Uno. RTFM

Because you did not post the full program we cannot tell what pins you are using.

…R

sample = analogRead(0);
      if (sample < 1024)

seems pretty pointless to me.