Kaivuritesti 1

#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 = A0; // initialize the A0analog pin for potentiometer
int potentio2 = A1; // initialize the A1analog pin for potentiometer
int potentio3 = A2; // initialize the A2analog pin for potentiometer
int potentio4 = A3; // initialize the A3analog 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

}

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);


}