Project FIVE tutorial - UNO KIT - ServoMotor Power

I have an overload problem on the Surface when I run the sketch to use a Servo motor. Suppose it is the motor requiring more power than available. This happens at one extreme of the potentiometer range. Am I right?

Is there a solution? Perhaps a separately powered HUB?

Thank you
Flavio

flavios:
This happens at one extreme of the potentiometer range.

That makes me wonder if you are trying to drive the servo past its internal end stop. Doing that is bad for the servo - it may damage the gears or burn out the motor. Many servos cannot move a full 180 degrees. You need to experiment to find the limits for your servo.

People here are not generally familiar with the tutorials in any kit. Please post the program you are trying and tell us in more detail what happens when you run it and what you want it to do that is different.

...R

Yes, sorry. The 5th Project was "coupling" the movement of the motor with that of the potenziometer via analog port A0.

What really happens is that the motor doesn't move but I was just looking at the serial print that relies the values raw and as an angle.

I suppose your preliminary idea is to the point. I was already trying to limit the pot range but I panic with the message from the PC because I would rather not damage the ONLY USB port I have on the Surface (and the UNO!). You'll find the sketch attached.

Many thanks
Flavio

PROGETTO5_v1.ino (441 Bytes)

Code from Reply #2 so others don't have to download it - See How to use the Forum

// Sketch PROGETTO 4 - FS20200212

#include <Servo.h>;
Servo myServo;

int const potPin = A0;
int potVal;
int angle;

void setup() {
  myServo.attach(9);
  Serial.begin(9600);
}

void loop() {
  potVal = analogRead(potPin);
  Serial.print("potVal:  ");
  Serial.print(potVal);
  
  angle = map(potVal,0,1023,0,179);
  Serial.print("     angle:  ");
  Serial.println(angle); 

  myServo.write(angle);
  delay(15);
}

...R

To start with change this line

angle = map(potVal,0,1023,0,179);

to

angle = map(potVal, 0, 1023, 50, 130);

which will greatly reduce the range of movement. If that works without problems you can gradually change the values back towards the original - testing after each change.

but I panic with the message from the PC

You have not posted the message

...R

Solved. Thanks you.
F

Simple servo test code you might use to determine the command values at which the servo starts to hit the internal mechanical stops.

// zoomkat 7-30-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
}

void loop() {

  while (Serial.available()) {

    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
      delay(3);
    } 
  }

  if (readString.length() >0) {
    Serial.println(readString);
    int n = readString.toInt();
    Serial.println(n);
    myservo.writeMicroseconds(n);
    //myservo.write(n);
    readString="";
  } 
}

Thanks, will try.
F