Using the Photoresistors

Theo Chemel

The photoresistors are components used to detect brightness. Like a potentiometer changes resistance as the knob is turned, a photoresistor changes resistance as the light level changes. By measuring this change in resistance, we can determine the amount of light hitting the photoresistor.


Wiring the photoresistors


Programming with the photoresistors

The example sketch below will read the brightness value from each photoresistor and print it to the serial monitor to be plotted.


void setup() {
  Serial.begin(9600);
}


void loop() {
  int reading1 = analogRead(A0);
  int reading2 = analogRead(A1);
  int reading3 = analogRead(A2);
  Serial.print(reading1);
  Serial.print("\t");
  Serial.print(reading2);
  Serial.print("\t");
  Serial.println(reading3);
}