Skip to content

Instantly share code, notes, and snippets.

@Bouhnosaure
Created May 21, 2015 09:25
Show Gist options
  • Save Bouhnosaure/18cab1baf3bfa2342ab2 to your computer and use it in GitHub Desktop.
Save Bouhnosaure/18cab1baf3bfa2342ab2 to your computer and use it in GitHub Desktop.
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
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(photocellPin);
/*Serial.print("Analog reading = ");*/
Serial.println(photocellReading); // the raw analog reading
// We'll have a few threshholds, qualitatively determined
/* if (photocellReading < 10) {
Serial.println(" - Noir");
} else if (photocellReading < 200) {
Serial.println(" - Sombre");
} else if (photocellReading < 500) {
Serial.println(" - Lumiere");
} else if (photocellReading < 800) {
Serial.println(" - Lumineux");
} else {
Serial.println(" - Tres lumineux");
}*/
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment