How to make the photoresistor more satiable ?

I try to control the rotation of the servo(0-120 degrees) with a photoresistor. When I connect a 470-ohm resistor in series with the photoresistor, the range of motion of the arm is usually between (0-15 degrees) unless I shine a really bright light. However, when I use a 2.2k resistor the arm can rotate in full motion without I shine other light. I wonder why analog in Pin doesn’t measure a high voltage when I use a small resistor.

#include <Servo.h>
Servo myServo;
int const photSenserPin = A0;
int photVal;
int angle;
void setup() {
myServo.attach(9);
Serial.begin(9600);
}
void loop() {
photVal = analogRead(photSenserPin);
Serial.print("photVal: ");
Serial.print(photVal);

angle = map(photVal, 0, 1023, 0, 120);
Serial.print(", angle: ");
Serial.println(angle);
myServo.write(angle);
delay(15);
}

Untitled document.pdf (446 KB)

I wonder why analog in Pin doesn't measure a high voltage when I use a small resistor.

To answer that question, study how voltage dividers work.

Measure the input to A0 with several different resistors. What do you notice? Also look at the data sheet for your photocell? So what do you conclude?

Ron

angle = map(photVal, 0, 1023, 0, 120);

the range of your photoresistor voltage drop should be 0-5V for that line of code there, if you series a resistor, you lose range by the ofset of the voltage drop of series resistor. Maybe map the pot val to match the maximum analog input difference that you can get.... like angle = map(photVal, 0, 500, 0, 120); or simmilar... first measure your A0 extremes, then adjust map, or desighn your external circuit so your photoresistor can change A0 from 0 to 5V