Actuator

๐Ÿš— Smart Car Robot Gear Motor (TT Motor, 1:48)

๐Ÿ“Œ Description

The TT motor is a small DC gear motor commonly used in smart car robots. It runs on 3Vโ€“6V and has a gear ratio of 1:48, which provides good torque for driving wheels.

โš ๏ธ Safety Note

  • The ESP32 (D1 R32) cannot supply enough current to drive the motor directly.
  • Always connect the motor through a motor driver (L298N), which acts as a bridge between the microcontroller and the motor.
  • The ESP32 only sends control signals to the L298N; the driver then powers the motor safely.

๐Ÿ‘‰ Think of the L298N as the robotโ€™s muscle controller โ€” the ESP32 gives the orders, and the driver powers the motor.


๐Ÿ–ฅ๏ธ Code Explanation

import machine
import time

pin16 = machine.Pin(16, machine.Pin.OUT)   # Control pin A (to L298N IN1)
pin17 = machine.Pin(17, machine.Pin.OUT)   # Control pin B (to L298N IN2)

while True:
    pin16.value(1)   # Motor forward (IN1 = HIGH, IN2 = LOW)
    pin17.value(0)
    time.sleep(1)

    pin16.value(0)   # Motor backward (IN1 = LOW, IN2 = HIGH)
    pin17.value(1)
    time.sleep(1)

Step by Step

  1. pin16 and pin17 โ†’ These pins send signals to the L298N motor driver.
  2. pin16.value(1), pin17.value(0) โ†’ Motor spins forward.
  3. pin16.value(0), pin17.value(1) โ†’ Motor spins backward.
  4. time.sleep(1) โ†’ Each direction lasts for 1 second before switching.

๐Ÿ‘‰ Together, this program makes the motor alternate between forward and backward motion.


โœ… Conclusion of the Test

  • If the motor spins forward for 1 second, then backward for 1 second, the program is working correctly.
  • This test shows how the robot can control motor direction using the L298N driver.
  • Later, you can expand this to control two motors for a full smart car, add PWM signals for speed control, or integrate sensors for autonomous driving.
On this page