Week 6 · Drivers & Motors

Session 28: DC motors and the H-bridge

Teach & build120 minLesson 18: DC Motors & H-Bridges

Learning outcomes

  • Explain how an H-bridge reverses a DC motor
  • Control direction with IN1 and IN2 and speed with PWM on ENA
  • Stop before reversing to protect the motor and driver
  • Measure motor supply current at different duty cycles

Kit and components

  • Uno, L298N or TB6612 module, small DC motor, separate motor supply, 10 kΩ potentiometer, jumpers
  • Multimeter

Pre-reading about 20 min

Students read these on their phones before class. They are listed on the student Before class page.

  1. Lesson 18: What an H-bridge does
  2. Lesson 18: Module pins and truth table
  3. Lesson 18: Stop before reversing

Session plan

  1. 0:0010 min
    Recap

    Quiz: servos

  2. 0:1020 min
    Demo

    The truth table

    Drive IN1 and IN2 by hand with jumpers to 5 V and GND and show forward, reverse, coast and brake before any code.

  3. 0:3035 min
    Build

    Forward, stop, reverse

    Students build the worked sketch, then add the potentiometer to set the speed.

  4. 1:0545 min
  5. 1:5010 min
    Wrap-up

    Current against duty cycle

    Students record motor supply current at 25 %, 50 % and 100 % duty and note how it changes.

Checkpoint: ready to move on?

Each student's motor runs forward and in reverse with a stop between, at a speed set by the potentiometer.

Extension for fast finishers

Catch-up path

Test the module's truth table with jumpers before writing any code.

Homework and practice

Code Along 12.4 and 12.5.

Facilitator notes

  • An L298N drops about 2 V, so a 6 V motor on a 6 V supply runs slowly. A TB6612 drops far less.