your code likely reads a joystick to control the motors
just to make sure your wiring is fine, if you test this code, what happens ? (assuming motor1 and motor2 are the right pins)
const byte motor1DirPin = 3;
const byte motor2DirPin = 5;
void setup()
{
Serial.begin(115200);
pinMode(motor1DirPin, OUTPUT);
pinMode(motor2DirPin, OUTPUT);
}
void loop() {
digitalWrite(motor1DirPin, LOW);
digitalWrite(motor2DirPin, LOW);
delay(5000)
digitalWrite(motor1DirPin, HIGH);
digitalWrite(motor2DirPin, HIGH);
delay(5000)
}
if that works then you should explore how to deal with timing:
- Using millis() for timing. A beginners guide
- Several things at the same time
- Flashing multiple LEDs at the same time
- you might also benefit from studying state machines. Here is a small introduction to the topic: Yet another Finite State Machine introduction