Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[arduino code examples for MT4]-04 DC motor control by L298N driver chip
#1
Code:
/*
* Language: English | Русский: ../RU/DIR_DIR_PWM/ | Қазақ: ../KZ/DIR_DIR_PWM/
*
* This code demonstrates motor control using the AlashMotorControlLite library.
* It sets different rotation speeds for the motor with delays between them.
* Code written for Alash engineering.
*/
#include "AlashMotorControlLite.h"
// Create motor object with DIR_DIR_PWM mode and pins inA = 4, inB = 5, PWM = 6
AlashMotorControlLite motor(DIR_DIR_PWM, 39, 46, 9);
void setup() {
}
void loop() {
  motor.setSpeed(100); // Set forward rotation speed
  delay(3000); // Delay 3 seconds

  motor.setSpeed(0); // Stop motor
  delay(3000); // Delay 3 seconds

  motor.setSpeed(-100); // Set reverse rotation speed
  delay(3000); // Delay 3 seconds

  motor.setSpeed(0); // Stop motor
  delay(3000); // Delay 3 seconds
}
arduino ino file download: 

.zip   motor.zip (Size: 560 bytes / Downloads: 18)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:

.zip   motor.ino.merged.zip (Size: 184.36 KB / Downloads: 9)
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)