Week 6 · Drivers & Motors
Session 28: DC motors and the H-bridge
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.
Session plan
- 0:0010 minRecap
Quiz: servos
- 0:1020 minDemo
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.
- 0:3035 minBuild
Forward, stop, reverse
Students build the worked sketch, then add the potentiometer to set the speed.
- 1:0545 minCode Along
Motors and the H-bridge
- 1:5010 minWrap-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.