Sei sulla pagina 1di 6

Duel Motor Driver with Arduino using a SN754410NE

Quad H-Bridge IC.


A step by step project guide by ArduinoFun.com

www.ArduinoFun.com

– Think It – Build It – Share It -


Duel Motor Driver with Arduino using a SN754410NE Quad
Half H-Bridge
October 25, 2009

H-Bridge Setup

With this post I am going to show you how to use a SN754410NE Quad Half H-Bridge IC to
control two 12 volt DC Motors. I have added a video so that you can see the Duel Motor in
action. As you can see in the video, all the wires can be a little confusing to look at. To make
things easier to view and understand as we go along, I have also created an illustration for you to
refer to. You may also download a printable PDF file of this illustration. I have depicted an
Arduino board in the illustration, if you already have one you are good to go, if not… you can do
like I have and Build Your Own Arduino following another one of my tutorials.

Here is the recommended parts you will need in order to complete this project. I have provided
sources where you can purchase items from and their prices.

1. Arduino board – $29.95 at CuriousInventor.com or…


2. Build Your Own Arduino – Total build cost $15.95 at ArduinoFun.com
3. SN754410 Quad Half H-Bridge – $2.50 available at ArduinoFun.com
4. 840 Tie Point Breadboard – $6.95 available at ArduinoFun.com
5. Wire Jumper Kit – $12.95 available at ArduinoFun.com
6. Two DC Motors – $3.99 ea. available at ArduinoFun.com
H-Bridge Pinout

As you are looking at the SN754410NE chip, you will notice a u-shaped notch at one end. This
will help to identify pin 1.
Pins 1, 9, and 16 are +5V
Pin 8 is +12V and will run the +12V DC motors.
Pins 4, 5, 12, and 13 are for GND

DC Motors have two hook ups on them. If you hooked one up straight to the source power you
would have one lead going to positive and one lead going to GND.

For our H-Bridge driver, you will hook the left motor leads to pin 3 & 6. The right motor leads
will hook up to pins 11 & 14.

Connect h-bridge pin 2 to the Arduino digital pin 2, and h-bridge pin 7 to Arduino digital pin 3.
Connect h-bridge pin 10 to Arduino digital pin 8, and h-bridge pin 15 to Arduino digital pin 7

Once you have your h-bridge circuit completed, you can upload the sketch to your Arduino. The
sketch will cycle back and forth on the dc motors driving them forward and backwards and then
light an led connected to pin 13 on the arduino.

Arduino Sketch

1. // Use this code to test your motor with the Arduino board:
2.
3. // if you need PWM, just use the PWM outputs on the Arduino
4. // and instead of digitalWrite, you should use the analogWrite command
5.
6. // ————————————————————————— Motors
7. int motor_left[] = {2, 3};
8. int motor_right[] = {7, 8};
9. int ledPin = 13; // LED connected to digital pin 13
10.
11. // ————————————————————————— Setup
12. void setup() {
13. Serial.begin(9600);
14.
15. // Setup motors
16. int i;
17. for(i = 0; i < 2; i++){
18. pinMode(motor_left[i], OUTPUT);
19. pinMode(motor_right[i], OUTPUT);
20. pinMode(ledPin, OUTPUT);
21. }
22.
23. }
24.
25. // ————————————————————————— Loop
26. void loop() {
27.
28. drive_forward();
29. delay(1000);
30. motor_stop();
31. Serial.println("1");
32.
33. drive_backward();
34. delay(1000);
35. motor_stop();
36. Serial.println("2");
37.
38. turn_left();
39. delay(1000);
40. motor_stop();
41. Serial.println("3");
42.
43. turn_right();
44. delay(1000);
45. motor_stop();
46. Serial.println("4");
47.
48. motor_stop();
49. delay(1000);
50. motor_stop();
51. Serial.println("5");
52.
53. digitalWrite(ledPin, HIGH); // set the LED on
54. delay(1000); // wait for a second
55. digitalWrite(ledPin, LOW); // set the LED off
56. delay(1000); // wait for a second
57.
58. }
59.
60. // ————————————————————————— Drive
61.
62. void motor_stop(){
63. digitalWrite(motor_left[0], LOW);
64. digitalWrite(motor_left[1], LOW);
65.
66. digitalWrite(motor_right[0], LOW);
67. digitalWrite(motor_right[1], LOW);
68. delay(25);
69. }
70.
71. void drive_forward(){
72. digitalWrite(motor_left[0], HIGH);
73. digitalWrite(motor_left[1], LOW);
74.
75. digitalWrite(motor_right[0], HIGH);
76. digitalWrite(motor_right[1], LOW);
77. }
78.
79. void drive_backward(){
80. digitalWrite(motor_left[0], LOW);
81. digitalWrite(motor_left[1], HIGH);
82.
83. digitalWrite(motor_right[0], LOW);
84. digitalWrite(motor_right[1], HIGH);
85. }
86.
87. void turn_left(){
88. digitalWrite(motor_left[0], LOW);
89. digitalWrite(motor_left[1], HIGH);
90.
91. digitalWrite(motor_right[0], HIGH);
92. digitalWrite(motor_right[1], LOW);
93. }
94.
95. void turn_right(){
96. digitalWrite(motor_left[0], HIGH);
97. digitalWrite(motor_left[1], LOW);
98.
99. digitalWrite(motor_right[0], LOW);
100. digitalWrite(motor_right[1], HIGH);
101. }

Potrebbero piacerti anche