Pages: [1]   Go Down
Author Topic: Use PWM on enable pin of H Bridge for speed control ?  (Read 721 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
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.

Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 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:

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

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

Pages: [1]   Go Up
Jump to: