ModuLab logo ModuLab Build • Play • Explore
Login Register

Lesson 11: Motor Control

Lesson 11 - Motor Control With L298N Pupil Notes

Today we will make a motor spin safely using the L298N motor driver.

In This Lesson

Lesson 11 - Motor Control With L298N Pupil Notes

Today We Are Learning

Today we will make a motor spin safely using the L298N motor driver.

What You Will Be Able To Do

  • Name the important L298N pins.
  • Make a motor go forward and backward.
  • Change motor speed with a slider/PWM value.
  • Explain brake and coast in simple words.

Why We Need L298N

A Bluepill pin is like a small helper. A motor needs a stronger helper. L298N takes commands from Bluepill and sends enough power to the motor.

L298N Pins To Remember

  • ENA: Speed for Motor A
  • IN1 + IN2: Direction for Motor A
  • IN3 + IN4: Direction for Motor B
  • ENB: Speed for Motor B

Easy Direction Rules (Motor A)

  • Forward: IN1=1, IN2=0
  • Backward: IN1=0, IN2=1
  • Coast (slow down naturally): IN1=0, IN2=0
  • Brake (stop quickly): IN1=1, IN2=1

Speed Rule

ENA uses PWM:

  • 0 means stop
  • Bigger number means faster
  • Start low, then increase

Build Checklist

  • Bluepill GND connected to L298N GND
  • Motor power connected to L298N power input
  • Motor wires connected to output terminals
  • ENA, IN1, IN2 connected to Bluepill control pins

Try This

  1. Set low speed.
  2. Run forward.
  3. Stop.
  4. Run backward.
  5. Test coast and brake.

Think And Explain

  • Which pin controls speed?
  • Which pins control direction?
  • What is the difference between coast and brake?

Challenge

Make a mini routine:

  • forward 2 seconds
  • stop 1 second
  • reverse 2 seconds

Success Check

You pass if:

  • Motor changes direction when commanded.
  • Speed changes when PWM changes.
  • You can explain ENA IN1 IN2 IN3 IN4 ENB.
Related Lesson Links