Hi, im trying to get my project to work with multiple LDR's, i can get it working with one from the information from How to use photocells, LDRs, CdS cells, photoresistors! but m having trouble getting it to work with multiple ones (i need it with 5). I have modified the code so it is now
/* Photocell simple testing sketch.
Connect one end of the photocell to 5V, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
For more information see www.ladyada.net/learn/sensors/cds.html */
int photocellPin0 = 0; // the cell and 10K pulldown are connected to a0
int photocellPin1 = 1; // the cell and 10K pulldown are connected to a1
int photocellPin2 = 2; // the cell and 10K pulldown are connected to a2
int photocellPin3 = 3; // the cell and 10K pulldown are connected to a3
int photocellPin4 = 4; // the cell and 10K pulldown are connected to a4
int photocellPin5 = 5; // the cell and 10K pulldown are connected to a5
int photocellReading; // the analog reading from the analog resistor divider
void setup(void) {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
}
void loop(void) {
photocellReading = analogRead(photocellPin0);
photocellReading = analogRead(photocellPin1);
photocellReading = analogRead(photocellPin2);
photocellReading = analogRead(photocellPin3);
photocellReading = analogRead(photocellPin4);
photocellReading = analogRead(photocellPin5);
Serial.print("Analog reading = ");
Serial.print(photocellReading); // the raw analog reading
// We'll have a few threshholds, qualitatively determined
if (photocellReading < 10) {
Serial.println(" - Dark");
} else if (photocellReading < 200) {
Serial.println(" - Dim");
} else if (photocellReading < 500) {
Serial.println(" - Light");
} else if (photocellReading < 800) {
Serial.println(" - Bright");
} else {
Serial.println(" - Very bright");
}
delay(1000);
}
This compiles fine but im not sure how to set up the components on the breadboard...any suggestions? Thanks!