Please Help, Controlling Servo based on Analog In

I’m a sophmore engineeriing student taking his first EE class, and I’m working on my final project, due tomorrow. I’m trying to set a servo to rotate based on the voltage of a circuit based on a photoresistor, and I cannot for the life of me figure out the pulse width and that. I’ve attached teh servo, I think I’ve figured out teh max pulse and minimum pulse width, but I can’t figure out how to configure the position of the servo based on the analog data in. Right now, I’ve got something that looks like this:
for pulsewidth = 1000
myservo.write(0)
for pulsewidth = 2000
myservo.write(180)

then I’m thinking of something along the lines of
for 1000 < pulsewidth < 2000
myservo.write(y)
y = EQUATION

Can anyone help?

I ended up with this, which i think, hope, and pray will work, but when I try to upload, it says “error: expected unqualified-id before numeric constant In function ‘void loop()’:”
Please help! I’m really starting to lose it here, lol.

/* Sound System
*Meant to run a servomotor based on the input from a photoresistor
circuit.
*/
pinMode(0, INPUT) //sets pin 0 to the analog input
servo myservo // creates a servo object to control servo
int pos = 0
void setup()
{
myservo.attach(9, 1000, 2000); //attaches the servo to pin 9
on the board, with the minimum pulse width corresponding to 0
degrees and the pulse maximumwidth corresponding to 180 degrees
}
void loop()
{
for pulsewidth = 1000
{
myservo.write(0)
}
for pulsewidth = 2000
{
myservo.write(180)
}
for 1000 < pulsewidth < 2000
{
myservo.write(y)
delay(30) //Causes the servo to delay 30ms before moving again
}
y = .18(pulsewidth) + 1000

Hello? Sorry to be a bother, but I’ve been working on this for a week, I’ve asked my professor, I’ve searched, and I must be missing something really basic, you know? It’s due tomorrow and I’m pulling a all nighter to try and freaking fix it.

If thats what your trying to compile using the Arduino software it looks like your missing rather a lot :-/

// comments only work on one line not two

you need lots of ;

theres no sign of a servo library, or any other method of outputting the pulse train to the servo.

It can be done with a few variables and 3 or 4 lines of code when using a servo library :)

Thank you very much. I'll work on it. We really haven't done anything with the board or programming before, so I'm learning everything from scratch.

I really don't know what a servo library is, and I constantly seem to be missing a few things when I try and figure it out. I really wish he had taken a week to go over teh programming with us.

servo myservo // creates a servo object to control servo
int pos = 0

You'll need semi-colons here! That's the cause of the error message you quoted.

servo myservo; // creates a servo object to control servo
int pos = 0;

And:

pinMode(0, INPUT)  //sets pin 0 to the analog input

This function call must be inside the 'setup()' function:

void setup ()
{
   pinMode(0, INPUT);  //sets pin 0 to the analog input
   ...
}

pinMode(0, INPUT) //sets pin 0 to the analog input

remove that statement, you do not set pin mode on analog inputs (its done for you under the covers when you call analogRead)