#include <Stepper.h>
#include <Servo.h>
#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL_PIN 2
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 myStepper(stepsPerRevolution, 8, 9, 10, 11);
Servo myservo; // create servo object to control a servo
int potpin = (0,1); // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL_PIN, INPUT_PULLUP);
myservo.attach(6);
myStepper.setSpeed(100);
}
void loop() {
int vert = analogRead(VERT_PIN);
int horz = analogRead(HORZ_PIN);
bool selPressed = digitalRead(SEL_PIN) == LOW;
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(0);
// step one revolution in one direction:
myStepper.step(stepsPerRevolution);
delay(0);
}