#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.
Raybom
-
I don't know Proteus - does it automagically connect the VCC and GND pins of the Uno to sensible nets?Mat– Mat12/05/2021 07:42:39Commented Dec 5, 2021 at 7:42
-
@Mat yes also you can see from voltmeter I can change voltage with potentiometer.Raybom– Raybom12/05/2021 12:54:45Commented Dec 5, 2021 at 12:54
-
@Mat I dont know you mentioned about VCC on arduino but yeah I solve the problem with connecting 5V into Arduino's VCC pin. Thanks.Raybom– Raybom12/05/2021 13:14:01Commented Dec 5, 2021 at 13:14
-
2Please take the tour to learn how this site works. Especially, please don't mark a question with "[SOLVED]", this is not a forum. Instead, write an own answer and mark, after you are allowed to do it. Visitors select answered question after the number of answers and the green mark, not by the title.the busybee– the busybee12/05/2021 13:24:15Commented Dec 5, 2021 at 13:24
-
1Oh, you put your solution as the comment on your edit--that makes it very difficult to see. You should write up your work as an answer, and give yourself a green checkmark for solving your own problem. Or at the very least, copy your edit summary message into your question.Dave X– Dave X12/05/2021 15:30:02Commented Dec 5, 2021 at 15:30
1 Answer 1
I came up solution by connecting 5V into Arduino's VCC pin.