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 AIN1+IN2: Direction for Motor AIN3+IN4: Direction for Motor BENB: 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,IN2connected to Bluepill control pins
Try This
- Set low speed.
- Run forward.
- Stop.
- Run backward.
- 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.
