1

Basically I want my motor to run after let's say 10 seconds passed since the program started up.

The amount of time is determined by user input, and I have already coded for that. The motor is connected to a breadboard and powered by a 9v battery, also connected to the breadboard.

The thing is, the motor runs as soon as I connect it to the breadboard. How can I use the Arduino board to make the motor wait 10 seconds before it moves? I am new to both circuitry and code... Sorry for my cluelessness.

Thanks so much.

  • 2
    Please first post your current code so we have somethign to start from. – jfpoilpret Feb 5 '17 at 22:30
3

You will need to add a logic level mosfet of the appropriate size and specs to control the power to the motor. You can drive the gate of the mosfet from a pin through a current limiting resistor with a larger bleed resistor. For a brushed motor you'll need a ceramic RF supressor cap plus flyback diode for back EMF protection:

schematic

simulate this circuit – Schematic created using CircuitLab

For greater RF supression (if your motor is pretty beefy) you can use a 0.1uF between each input lead and the motor case.

When you turn the pin on, motor turns on, low turns off. Using analog and appropriate R values you can control motor speed (setting 0-255):

int motorControl = [your pin];

void setup()
{
  pinMode(motorControl, OUTPUT);
}

void loop()
{
  delay(10000); // delay 10 seconds plus board boot time
  analogWrite(motorControl, 255); // turn motor on full
}

You can time the delay with a stop watch and adjust to be exactly 10s by dropping the delay() call to compensate for the boot up time of the board.

More about MOSFETS here:

https://electronics.stackexchange.com/questions/81935/mosfet-usage-and-p-vs-n-channel

  • Just a question: why the 220 Ohm resistor? – frarugi87 Feb 6 '17 at 9:23
  • 1
    As mentioned several times, it serves to limit the current to protect the arduino when having to charge the capacitance of the MOSFET gate. The outputs expect something on the order of pF so trying to charge the nF capacitance overstresses. Without the current limiting resistor, the arduino will eventually fail and likely take the MOSFET (and possibly other pieces) with it if the MOSFET goes linear and overheats. – Dave Johnson Feb 7 '17 at 5:11
0

I would recommend connecting the motor to a controller of some sort of a controller, maybe a relay or something like that, and then write some code that waits 10 seconds, and then turns on your controller / relay. That will turn on the motor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.