Reads in the amount of light around it, outputs to the serial box how light/dark it is.
int photoCellPin = 0;
int photoCellReading;
void setup(void)
{
Serial.begin(9600);
}
void loop(void)
{
photoCellReading = analogRead(photoCellPin);
Serial.print("analog reading = ");
Serial.print(photoCellReading);
if (photoCellReading < 10)
{Serial.println(" - Very Dark");}
else
if (photoCellReading < 100)
{Serial.println(" - Dark");}
else
if (photoCellReading < 200)
{Serial.println(" - Dim");}
else
if (photoCellReading < 500)
{Serial.println(" - Light");}
else
if (photoCellReading < 600)
{Serial.println(" - Lighter");}
else
if (photoCellReading < 800)
{Serial.println(" - Bright");}
else
{Serial.println(" - Very Bright");}
delay(1000);
}
Sunday, March 7, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment