// this code is for the yellow Keyes L298 motor shield
// this code will run the motors FWD for 1 second
// this code runs to motors at 50% duty cycle
// code tested 20 September 2025
int DIRA = 12; // rotation direction depends on whether this pin is HIGH or LOW
int DIRB = 13; // rotation direction depends on whether this pin is HIGH or LOW
int ENA = 3; // PWM signal is addressed to the enable pin [3]
int ENB = 11; // PWM signal is addressed to the enable pin [11]
void setup()
{
delay(1111); // STARTING WAIT-OR-DELAY
// ------------- STAGE 1 --------- drive robot forward -----------------
digitalWrite(DIRA, LOW);
analogWrite(ENA, 99); // 0 = 0% 128 = 50% 255 = 100%
digitalWrite(DIRB, HIGH);
analogWrite(ENB, 99); // was: 200
delay(1111); // original value: 1000
analogWrite(ENA, 0); // this line of code stops the PWM function
analogWrite(ENB, 0); // this line of code stops the PWM function
delay(1000); // original value: 1000
// ------------- STAGE 2 --------- pivot robot to the right -----------------
digitalWrite(DIRA, HIGH);
analogWrite(ENA, 99); // 0 = 0% 128 = 50% 255 = 100%
digitalWrite(DIRB, HIGH);
analogWrite(ENB, 99); // was: 200
delay(300); // original value: 1000
analogWrite(ENA, 0); // this line of code stops the PWM function
analogWrite(ENB, 0); // this line of code stops the PWM function
delay(1000); // original value: 1000
// ------------- STAGE 3 --------- drive robot forward -----------------
digitalWrite(DIRA, LOW);
analogWrite(ENA, 99); // 0 = 0% 128 = 50% 255 = 100%
digitalWrite(DIRB, HIGH);
analogWrite(ENB, 99); // was: 200
delay(555); // original value: 1000
analogWrite(ENA, 0); // this line of code stops the PWM function
analogWrite(ENB, 0); // this line of code stops the PWM function
delay(1000); // original value: 1000
// ------------- STAGE 4 --------- pivot robot to the right -----------------
digitalWrite(DIRA, LOW);
analogWrite(ENA, 99); // 0 = 0% 128 = 50% 255 = 100%
digitalWrite(DIRB, LOW);
analogWrite(ENB, 99); // was: 200
delay(300); // original value: 1000
analogWrite(ENA, 0); // this line of code stops the PWM function
analogWrite(ENB, 0); // this line of code stops the PWM function
delay(1000); // original value: 1000
}
void loop()
{
}