#include <Arduino.h>
#include <L293D.h>
L293D motor(15,2,4);
// // Left Motor connections
// int enL = 25, in1 = 26, in2 = 27;
// // Right Motor connections
// int enR = 13, in3 = 12, in4 = 14;
// L298N LeftMotor(enL, in1, in2);
// L298N RightMotor(enR, in1, in2);
//ESP32
// L293D(int Motor1, int Motor2 = -1, int enablePin = -1, int pwmChannel = 0);
// bool begin(bool usePwm = false, int frequency = 1000, int resolution = 8);
// bool Stop();
// bool SetMotorSpeed(int speed);
void setup(){
Serial.begin(115200); // Initialize the serial communication for debugging
motor.begin();
motor.SetMotorSpeed(100);
// Turn off motors - Initial state
// digitalWrite(in1, LOW);
// digitalWrite(in2, LOW);
// digitalWrite(in3, LOW);
// digitalWrite(in4, LOW);
}
void loop(){
// Set motor speed and direction with a double value between -1 and 1
motor.set(.75); // 75% power forward
delay(2500);
motor.set(-.3); // 30% power reverse
delay(2500);
// Set motor speed and direction with an int value between -255 and 255
motor.set(200);
delay(2500);
motor.set(-150);
delay(2500);
// Use motor.get() to get current speed and then update it from that
motor.set(-255);
while(motor.get() != 255)
{
motor.set(motor.get() + 5); // Increment motor speed from previous speed
Serial.println(motor.get());
delay(100); // Delay 100ms to see the speed changing
}
}