Pages: [1]   Go Down
Author Topic: Use PWM on enable pin of H Bridge for speed control ?  (Read 768 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Offline Offline
Faraday Member
Karma: 16
Posts: 2855
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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

Pages: [1]   Go Up
Jump to: