Project 5 - need help

Hi all,

I'd really appreciate some help with project 5 - I'm guessing I'm missing something big.
Here's my code:
// 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 serial connection
}

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

// scale the numbers from the potentiometer
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
delay(15);
}

and attached is a photo of the board. I've tried a new motor, new wires, new pot, new breadboard... same result. The servo just spins with no change if I rotate the pot. I've checked the pot with a multimeter, and am confident i have that right...

Really appreciate any advice!

many thanks
Leila

Hi,

Looking at the picture of the project, it seems the yellow wire from the servo is going to pin 10 & not pin 9. Is that so?

Cheers

Thanks Roduino!

it is hooked up to pin 9. any other thoughts?

Leila

Check the data (centre) pin of the pot is on the same side as the wire to A0.

If your still using a pot from the kit, the pot that I used, I placed in the middle of the board , had 2 pins on one side of the board & the centre(data) pin on the other side(ie. lower side of yours) , if yours is similar placement shoudn't the wire to A0 go on the othe(lower) side of the board??

If so see p23, re: middle row breaks connection.

Cheers

THAT WAS IT!!! Oh Roduino thanks so very very much!!!! :slight_smile: