Go Down

Topic: Servo motor not working (Read 718 times) previous topic - next topic

nickelnoff

Hello - this is our first post.

We are trying to get Project 05 - Mood Cue - from the Starter Kit working.

We are almost there however the servo motor is not spinning and making a clicking noise.


The Serial Monitor is showing variable pot and angle values but no activity on the servo.


Anything we can do here or do we most likely have a broken servo ?

UKHeliBob

Quote
Anything we can do here
Start by posting your code but please see Read this before posting a programming question and follow the advice given.

How is the servo powered ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

nickelnoff

The code is the standard code from the project p05-ServMoodIndicator - it is follows:

Code: [Select]

/*
  Arduino Starter Kit example
  Project 5 - Servo Mood Indicator

  This sketch is written to accompany Project 5 in the Arduino Starter Kit

  Parts required:
  - servo motor
  - 10 kilohm potentiometer
  - two 100 uF electrolytic capacitors

  created 13 Sep 2012
  by Scott Fitzgerald

  http://www.arduino.cc/starterKit

  This example code is part of the public domain.
*/

// include the Servo library
#include <Servo.h>

Servo myServo;  // create a servo object

int const potPin = A0; // analog pin used to connect the potentiometer
int potVal;  // variable to read the value from the analog pin
int angle;   // variable to hold the angle for the servo motor

void setup() {
  myServo.attach(9); // attaches the servo on pin 9 to the servo object
  Serial.begin(9600); // open a serial connection to your computer
}

void loop() {
  potVal = analogRead(potPin); // read the value of the potentiometer
  // print out the value to the Serial Monitor
  Serial.print("potVal: ");
  Serial.print(potVal);

  // scale the numbers from the pot
  angle = map(potVal, 0, 1023, 0, 179);

  // print out the angle for the servo motor
  Serial.print(", angle: ");
  Serial.println(angle);

  // set the servo position
  myServo.write(angle);

  // wait for the servo to get there
  delay(60);
}


The servo is powered through the USB cable from my laptop (which is plugged in to power)

Thanks !

UKHeliBob

Check the wiring to the servo.  Exactly how is it connected to the Arduino and power ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

nickelnoff

We fixed it! The capacitor was badly connected :)

Thanks for you help!

UKHeliBob

What is the purpose of the capacitor and how is it connected to the circuit ?

Quote
The servo is powered through the USB cable from my laptop (which is plugged in to power)
I don't understand what you have said.  Is the servo getting its current via the Arduino ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

nickelnoff

Correct - the servo is receiving power via Arduino. The Arduino is powered via USB,

UKHeliBob

Does the Sweep example work correctly ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up