Go Down

Topic: Use PWM on enable pin of H Bridge for speed control ? (Read 836 times) previous topic - next topic

GranddadFred

The topic says it all, can I use PWM on the Enable pin of the H Bridge for speed control of my robots motors?
Is there a tutorial I missed somewhere about this? Could someone post a sample of the program code?

something like this I'm assuming:

#define motor1a 9;
#define motor1b 10;
#define enable1 11;
int speed
void setup ();
   pinMode (motor1a, OUTPUT)
   pinMode (motor1b, OUTPUT);
   pinMode (enable1, OUTPUT);
void loop ();
   digitalWrite(motor1a, HIGH);
   digitalWrite(motor1b, LOW);
   //heres where i'm lost
   USE PWM (enable1, speed) // something like that.


RuggedCircuits

You can use the analogWrite() function where you write "USE PWM".

Here's some sample code for our Rugged Motor Driver which uses full power (i.e., analogWrite(EN1_PIN, 255)) but you can use a number from 0 to 255 to control the power:

http://ruggedcircuits.com/AD030/rmcbasic.pde

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

Go Up