#include <Servo.h>
#define potpin A0
int savebutton=2;
int button1=3;
int button2=4;
int button3=5;
Servo servo1;
Servo servo2;
Servo servo3;
int servo1ipos=90;
int servo2ipos=90;
int servo3ipos=90;
int val=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(savebutton,INPUT);
pinMode(button1,INPUT);
pinMode(button2,INPUT);
pinMode(button3,INPUT);
servo1.attach(6);
servo2.attach(7);
servo3.attach(8);
servo1.write(servo1ipos);
servo2.write(servo2ipos);
servo3.write(servo3ipos);
}
void loop() {
// put your main code here, to run repeatedly:
servocontrol();
}
int servocontrol(){
if(digitalRead(button1)==LOW){
potvalue();
Serial.println(val);
servo1.write(val);
delay(200);
}
}
int potvalue(){
val=analogRead(potpin);
}
Basicly I only read 1023 value instead of potentiometer value I couldnt figure it out need help.
Update: I came up solution by connecting 5V into Arduino's VCC pin.