Hi!
I'm really new to coding and using Arduino, so trying my hope here getting some help! I've looked at some other posts about this topic, but I can't come up with a conclusion to what the problem is.
I've modeled and 3D-printed my own little robot-arm, that I want to control using 4x SG90 micro servos with potentiometers (it says B10K on them). I started by just trying to connect one or two just to test, but the servos looks like they are having a seizure once i power it up. Looking at the readings from the potentiometers, the values are fluctuating a lot, and my guess would be that this might be the problem. Anyone that has any idea what the cause/problem is? What can I do?
#include <Servo.h>
//Define the servo's
Servo klo;
Servo ledd1;
//Inputs
int potPin1 = A3;
int potVal1 = 0;
int potPin2 = A4;
int potVal2 = 0;
void setup() {
Serial.begin(9600);
klo.attach(5);
ledd1.attach(3);
}
void loop() {
potVal1 = analogRead(potPin1);
Serial.println(potVal1); //Reads the value from the potentiometer
potVal1 = map(potVal1, 0, 1023, 0 , 180); //Scale it to use it with the servo (values from 0 to 180)
klo.write(potVal1); //Sets the servo position according to the scaled value
delay(10);
potVal2 = analogRead(potPin2);
Serial.println(potVal2);
potVal2 = map(potVal2, 0, 1023, 0 , 180);
ledd1.write(potVal2);
delay(10);
}