Loading...
Pages: 1 [2]   Go Down
Author Topic: [HELP] Set the speed of 2 DC motors with H-Bridge  (Read 387 times)
0 Members and 1 Guest are viewing this topic.
East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 47
Posts: 1381
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That link does not work for me.

Does each motor work as expected when it is the only one being controlled ?

A thought.  Have you got anything using interrupts, such as a sensor using timer 2, attached to the Arduino ?
I had problems with motor control when I added a ping sensor to my buggy. (Arduino Uno)  It stopped PWM working on pins 3 and 11 because its library uses timer 2 which is also used for PWM on those pins.  I had to switch the enable pin of one motor from pin 3 to pin 10.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, the picture is in the attach.
Yes, you can control one motor, but then the other one does nothing.
And no, I don't use any sensor, just a button and a few LED's smiley
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 385
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

try moving the enable switch to another free PWM pin. that should give you the speed control you need
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you mean 'PWM pin'?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 137
Posts: 19001
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What do you mean 'PWM pin'?
http://arduino.cc/en/Reference/AnalogWrite
Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, I'll try tomorrow
Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 47
Posts: 1381
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, the picture is in the attach.
Yes, you can control one motor, but then the other one does nothing.
And no, I don't use any sensor, just a button and a few LED's smiley
Looking at your code and judging by the names used for the Arduino pins you have not wired your circuit the same as the example circuit.  That will not matter as long as you have wired the enable and inputs of the H bridge to the pins that the names in your code suggest.  ie

Arduino pin  H bridge
5                2  IN1 - motor A
4                7  IN2 - motor A
6                 1 Enable motor A

3               10 IN3 - motor B
2               15 IN4 - motor B
7                 9 Enable motor B

I suggest that you check this carefully just in case.
Logged

Pages: 1 [2]   Go Up
Print
 
Jump to: