#include <Stepper.h>
#include <Servo.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper stepper1(stepsPerRevolution, 8, 10, 9, 11);
Stepper stepper2(stepsPerRevolution, 4, 6, 5, 7);
Servo rudderServo; // Create a servo object to control the rudder
int potPin = A0; // Pin to which the potentiometer is connected
int rudderPin = 12; // Pin to which the rudder servo is connected
int potValue; // Variable to store the potentiometer value
int rudderAngle; // Variable to store the angle of the rudder
void setup() {
// Set up the Stepper motors
stepper1.setSpeed(60);
stepper2.setSpeed(60);
// Set up the rudder servo
rudderServo.attach(rudderPin);
}
void loop() {
// Read potentiometer value
potValue = analogRead(potPin);
// Map potentiometer value (0-1023) to rudder angle (0-180)
rudderAngle = map(potValue, 0, 1023, 0, 180);
// Control the rudder angle
rudderServo.write(rudderAngle);
// Rotate stepper motors continuously in one direction
stepper1.step(1);
stepper2.step(1);
delay(10); // Delay for smooth operation, adjust as needed
}