Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Arduino DC motor control - PWM

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
17,070
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Mar 30, 2010

DC motor 24V 2A

to test how the motor handles variations in PWM.
2 potentiometers to vary the 'on' and 'off ' time of the pulse.

final result:
http://sites.google.com/site/thebluenoisedepartment/Goal-2008

test program :

int ledPin = 13; // LED connected to digital pin 13int h=1;

int h2=0;
int h3=0;
int h4=0;
int h5=0;

void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output




}




void loop() // run over and over again
{
digitalWrite(ledPin, HIGH); // sets the LED on h5 = analogRead(0); // read the value from the sensor
while(h5>0){
h2 = analogRead(0); // read the value from the sensor
while(h2>0){
h2--;
} h5--;
}


digitalWrite(ledPin, LOW); // sets the LED off h4 = analogRead(1)*2; // read the value from the sensor
while(h4>0){
h3 = analogRead(1); // read the value from the sensor

while(h3>0){
h3--;
}
h4--;
}

}

  • likes, 2 dislikes

Link to this comment:

Share to:
see all

All Comments (5)

Sign In or Sign Up now to post a comment!
  • Great job!

  • What do you need to run this motor? I saw the motor shield but how do you get mor amps into it?

  • Another question I am trying to control speed of a dc motor with a pot with arduino and the only thing I can find is a fading code for an LED when controlling a motor it just doesn't work that great especially when you use a fet driver because that amplifies the problems even more its like there is no ramp the motor just turns on half way through the rotation of the pot. Is the problem in the analogwrite?

  • Are you varying the frequency as well as the duty cycle with the two pots?

  • Hey what is the circuit element in between two pots in your circuit?

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more