Arduino DC motor control - PWM

www.youtube.com/watch?v=p5hzv6m_8fo

 

final result:

sites.google.com/site/thebluenoisedepartment

 

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.

 

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--;

}

 

}

 

9,297 views
1 fave
2 comments
Uploaded on July 16, 2008