Kaivuri testi neljällä servolla

#include <Servo.h> //Servo library


Servo servo_1; //initialize a servo object for the connected servo
Servo servo_2; //initialize a servo object for the connected servo
Servo servo_3; //initialize a servo object for the connected servo
Servo servo_4; //initialize a servo object for the connected servo

int angle1 = 0;
int angle2 = 0;
int angle3 = 0;
int angle4 = 0;

int potentio1 = A1; // initialize the A0analog pin for potentiometer
int potentio2 = A0; // initialize the A1analog pin for potentiometer
int potentio3 = A2; // initialize the A1analog pin for potentiometer
int potentio4 = A3; // initialize the A1analog pin for potentiometer

#define SERVO1PIN 7
#define SERVO2PIN 9
#define SERVO3PIN 10
#define SERVO4PIN 6

void setup()
{
  servo_1.attach(SERVO1PIN); // attach the signal pin of servo to pin9 of arduino

  servo_2.attach(SERVO2PIN); // attach the signal pin of servo to pin9 of arduino
  servo_3.attach(SERVO3PIN); // attach the signal pin of servo to pin9 of arduino
  servo_4.attach(SERVO4PIN); // attach the signal pin of servo to pin9 of arduino
}

void loop()
{
  angle1 = analogRead(potentio1); // reading the potentiometer value between 0 and 1023
  angle1 = map(angle1, 0, 1023, 60, 140); // scaling the potentiometer value to angle value for servo between 0 and 180)
  servo_1.write(angle1); //command to rotate the servo to the specified angle
  delay(5);

  angle2 = analogRead(potentio2); // reading the potentiometer value between 0 and 1023
  angle2 = map(angle2, 0, 1023, 0, 179); // scaling the potentiometer value to angle value for servo between 0 and 180)
  servo_2.write(angle2); //command to rotate the servo to the specified angle
  delay(5);
  
  angle3 = analogRead(potentio3); // reading the potentiometer value between 0 and 1023
  angle3 = map(angle3, 0, 1023, 30, 160); // scaling the potentiometer value to angle value for servo between 0 and 180)
  servo_3.write(angle3); //command to rotate the servo to the specified angle
  delay(5);

  angle4 = analogRead(potentio4); // reading the potentiometer value between 0 and 1023
  angle4 = map(angle4, 0, 1023, 30, 160); // scaling the potentiometer value to angle value for servo between 0 and 180)
  servo_4.write(angle4); //command to rotate the servo to the specified angle
  delay(5);

}