|
// responsive light
// by BARRAGAN <http://barraganstudio.com>
int val;
void setup()
{
// nothing for setup
}
void loop()
{
val = analogRead(0); // read analog input pin 0 (value in the range 0-1023)
// The luminosity of the LED will be proportional to te amount of light in the environment.
analogWrite(0, val/4); // write the value to PWM output pin 0 (value in the range 0-255)
// if you want the luminosity of the LED to be inversely proportional to the amount of
// of light in the environment comment the previous line and use the line below instead:
//analogWrite(0, 255-val/4);
delay(100); // wait 100ms for next reading
}
|