Skip to content

Motor driver circuit version 1

The diagram below shows how to construct a motor driver circuit, and you should be able to follow most of it without any trouble. However, there are also some new elements that you have not seen before. You should apply the same systematic approach as before.

The table below provides a structure and some suggested times for the different stages of the process.

Stage Time Description
Initial inspection 2min Identify those components that you are already familiar with, and also those which are new. Anything new may require special handling.
Questions arising 1 min Note down your questions as before: make them short but clear.
Background research 5 min Search for reference material and/or examples online. Remember to take a critical approach, and to compare several possible sources before choosing the ones you will rely on.
Answers to questions 5 min Take the time to note down your answers. Remember to include links where appropriate, and if any better ideas emerge during discussions, note them down as well.
Precautions to be taken 2 min Make a note of any special procedures or constraints that you will need to observe, especially with reference to the new elements.
Motor driver version 1 20 min Follow the diagram and construct the example circuit as shown. The code below is a simple test program that you can use to show whether your circuit works.

DC motors circuit DC motors circuit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
    int motor_left[] = {2, 3};
    int motor_right[] = {8, 9};
    int led = 13;

    void setup() {
    int i;
    for(i = 0; i < 2; i++){
    pinMode(motor_left[i], OUTPUT);
    pinMode(motor_right[i], OUTPUT);
    pinMode(led, OUTPUT);
    }
    }

    void loop() {

    led_on();
    delay(2000);
    led_off();
    delay(1000);

    drive_forward(1000);
    motor_stop(25);
    drive_backward(1000);
    motor_stop(25);
    turn_left(1000);
    motor_stop(25);
    turn_right(1000);
    motor_stop(1000);
    }


    void led_on(){
    digitalWrite(led, HIGH);
    }

    void led_off(){
    digitalWrite(led, LOW);
    }

    void motor_stop(int duration){
    digitalWrite(motor_left[0], LOW);
    digitalWrite(motor_left[1], LOW);

    digitalWrite(motor_right[0], LOW);
    digitalWrite(motor_right[1], LOW);

    delay(duration);
    }

    void drive_forward(int duration){
    digitalWrite(motor_left[0], HIGH);
    digitalWrite(motor_left[1], LOW);

    digitalWrite(motor_right[0], HIGH);
    digitalWrite(motor_right[1], LOW);

    delay(duration);
    }

    void drive_backward(int duration){
    digitalWrite(motor_left[0], LOW);
    digitalWrite(motor_left[1], HIGH);

    digitalWrite(motor_right[0], LOW);
    digitalWrite(motor_right[1], HIGH);

    delay(duration);
    }

    void turn_left(int duration){
    digitalWrite(motor_left[0], LOW);
    digitalWrite(motor_left[1], HIGH);

    digitalWrite(motor_right[0], HIGH);
    digitalWrite(motor_right[1], LOW);

    delay(duration);
    }

    void turn_right(int duration){
    digitalWrite(motor_left[0], HIGH);
    digitalWrite(motor_left[1], LOW);

    digitalWrite(motor_right[0], LOW);
    digitalWrite(motor_right[1], HIGH);

    delay(duration);
    }