#include <Servo.h>
// Create Servo objects for each motor
Servo motor1;
Servo motor2;
Servo motor3;
Servo motor4;
// Define the pins for each motor
const int motor1Pin = 9;
const int motor2Pin = 10;
const int motor3Pin = 11;
const int motor4Pin = 12;
void setup() {
// Attach each motor to its respective pin
motor1.attach(motor1Pin);
motor2.attach(motor2Pin);
motor3.attach(motor3Pin);
motor4.attach(motor4Pin);
}
void loop() {
// Example: Move all motors to 90 degrees
motor1.write(90);
motor2.write(90);
motor3.write(90);
motor4.write(90);
delay(1000); // Wait for 1 second
// Example: Move all motors to 0 degrees
motor1.write(0);
motor2.write(0);
motor3.write(0);
motor4.write(0);
delay(1000); // Wait for 1 second
// Example: Move all motors to 180 degrees
motor1.write(180);
motor2.write(180);
motor3.write(180);
motor4.write(180);
delay(1000); // Wait for 1 second
}