Want to see it in action?. Check out this video of the gadget at work:
Here is the code that runs it. No more, no less:
// ____ //
// / /___ //
// / / /___ //
// /____/ / /____ //
// | /____/ / /| //
// |___| /____/ / | //
// |___| /____/ / //
// |___| | / //
// |____|/ //
// ArduLightResponseSystem
// Led on only when the light is out.
int photoRPin = 0;
int lightLevel;
int LEDpin = 13;
void setup()
{
Serial.begin(9600);
}
void loop()
{
lightLevel=analogRead(photoRPin);
Serial.println(lightLevel);{
if(lightLevel > 526)
{
digitalWrite(13, HIGH);
}
else if(lightLevel <= 526){
digitalWrite(13, LOW);
}
delay(250);
}
}
//......................................................................
// Luis Rodriguez Alonso. October 2015. habitainer@gmail.com
// http://habican.blogspot.com.es/
// publicado bajo GNU GENERAL PUBLIC LICENSE
// https://gnu.org/licenses/gpl-3.0.en.html
Just enjoy it!