1

proteus schematic

#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.

6
  • I don't know Proteus - does it automagically connect the VCC and GND pins of the Uno to sensible nets?
    – Mat
    Dec 5, 2021 at 7:42
  • @Mat yes also you can see from voltmeter I can change voltage with potentiometer.
    – Raybom
    Dec 5, 2021 at 12:54
  • 2
    Please 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. Dec 5, 2021 at 13:24
  • 1
    Oh, 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
    Dec 5, 2021 at 15:30
  • 1
    @DaveX I added on my post thanks for information.
    – Raybom
    Dec 5, 2021 at 16:31

1 Answer 1

1

I came up solution by connecting 5V into Arduino's VCC pin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.