Mr. Seng Theara
DC Motor
How to make the DC Motor rotate
Power Supply
DC Motor
How to make the DC Motor rotate
Power Supply
How to make the DC Motor rotate
Voltage 12V
Voltage 6V
How to make the DC Motor rotate
Forward Direction
Backward Direction
Why we can't use ESP32 to control DC Motor Directly?
ESP32
Why we can't use ESP32 to control DC Motor Directly
DC Motor
ESP32
Why we can't use ESP32 to control DC Motor Directly
DC Motor
ESP32
Result
Why we can't use ESP32 to control DC Motor Directly
DC Motor
ESP32
Result
ESP32 may reset, overheat, or get permanently damaged
Motor won’t spin or spin slowly
Correct Way to Control a DC Motor with ESP32
ESP32
Motor Driver
Correct Way to Control a DC Motor with ESP32
ESP32
Motor Driver
TB6612
Correct Way to Control a DC Motor with ESP32
ESP32
Motor Driver
TB6612
L298N
Correct Way to Control a DC Motor with ESP32
ESP32
Motor Driver
TB6612
L298N
L293D
Correct Way to Control a DC Motor with ESP32
ESP32
Motor Driver
TB6612
L298N
L293D
BTS7960
Correct Way to Control a DC Motor with ESP32
ESP32
Motor Driver
TB6612
L298N
L293D
BTS7960
These drivers:
Supply high current
Protect ESP32
Allow speed & direction control
Correct Way to Control a DC Motor with ESP32
ESP32
Motor Driver
TB6612
L298N
L293D
BTS7960
These drivers:
Supply high current
Protect ESP32
Allow speed & direction control
| Driver | State |
|---|---|
| A01 | HIGH |
| A02 | LOW |
| PWMA | 8 bit (0-255) |
| B01 | HIGH |
| B02 | LOW |
| PWMB | 8 bit (0-255) |
| Motor |
|---|
Forward
Forward
| State |
|---|
| LOW |
| HIGH |
| 8 bit (0-255) |
| LOW |
| HIGH |
| 8 bit (0-255) |
| Motor |
|---|
Backward
Backward
| Motor1 | IO33 |
|---|---|
| AIN1 | IO26 |
| AIN2 | IO25 |
| Motor2 | IO14 |
| BIN1 | IO32 |
| BIN2 | IO27 |
| Motor3 | IO5 |
|---|---|
| AIN3 | IO21 |
| AIN4 | IO18 |
| Motor4 | IO19 |
| BIN3 | IO23 |
| BIN4 | IO22 |
| Motor1 | IO33 |
|---|---|
| AIN1 | IO26 |
| AIN2 | IO25 |
void setup() {
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
ledcSetup(0, 20000, 8);
ledcAttachPin(33, 8);
}
void loop() {
analogWrite(33, 70);
digitalWrite(25, HIGH);
digitalWrite(26, LOW);
}| Motor1 | IO33 |
|---|---|
| AIN1 | IO26 |
| AIN2 | IO25 |
void setup() {
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
ledcSetup(0, 20000, 8);
ledcAttachPin(33, 0);
}
void loop() {
ledcWrite(0, 70);
digitalWrite(25, HIGH);
digitalWrite(26, LOW);
}First, We need to declare pin 25 and 26 as output because it is used to control direction of the motor
| Motor1 | IO33 |
|---|---|
| AIN1 | IO26 |
| AIN2 | IO25 |
void setup() {
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
ledcSetup(0, 20000, 8);
ledcAttachPin(33, 0);
}
void loop() {
ledcWrite(0, 70);
digitalWrite(25, HIGH);
digitalWrite(26, LOW);
}First, We need to declare pin 25 and 26 as output because it is used to control direction of the motor
We set Channel 0 for Motor 1, and Frequency of 20Khz, with 8 bit resolution (0-255)
| Motor1 | IO33 |
|---|---|
| AIN1 | IO26 |
| AIN2 | IO25 |
void setup() {
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
ledcSetup(0, 20000, 8);
ledcAttachPin(33, 0);
}
void loop() {
ledcWrite(0, 70);
digitalWrite(25, HIGH);
digitalWrite(26, LOW);
}First, We need to declare pin 25 and 26 as output because it is used to control direction of the motor
We set Channel 0 for Motor 1, and Frequency of 20Khz, with 8 bit resolution (0-255)
We declare pin 33 as pwm1 because we use this pin to control the speed of the motor
| Motor1 | IO33 |
|---|---|
| AIN1 | IO26 |
| AIN2 | IO25 |
void setup() {
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
ledcSetup(0, 20000, 8);
ledcAttachPin(33, 0);
}
void loop() {
ledcWrite(0, 70);
digitalWrite(25, HIGH);
digitalWrite(26, LOW);
}First, We need to declare pin 25 and 26 as output because it is used to control direction of the motor
We set Channel 0 for Motor 1, and Frequency of 20Khz, with 8 bit resolution (0-255)
We declare pin 33 as pwm1 because we use this pin to control the speed of the motor
analogWrite to adjust the speed between 0-255
The pin 25 and 26 are used for switching the direction of the motor
| Motor1 | IO33 |
|---|---|
| AIN1 | IO26 |
| AIN2 | IO25 |
void setup() {
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
ledcSetup(0, 20000, 8);
ledcAttachPin(33, 0);
}
void loop() {
ledcWrite(0, 70);
digitalWrite(25, HIGH);
digitalWrite(26, LOW);
}First, We need to declare pin 25 and 26 as output because it is used to control direction of the motor
We set Channel 0 for Motor 1, and Frequency of 20Khz, with 8 bit resolution (0-255)
We declare pin 33 as pwm1 because we use this pin to control the speed of the motor
analogWrite to adjust the speed between 0-255
The pin 25 and 26 are used for switching the direction of the motor
Write code to control all the 4 motors
Write code to control all the 4 motors