/** 
 * Potentiomenter + LED intensity
 * by BARRAGAN <http://barraganstudio.com>
 * 
 * Reads values from a photoresistor connected to the 
 * analog input pin 0. The value read from the sensor is proportional
 * to the amount of light that hits the sensor surface.
 * The value read is used to dim a light connected to the PWM Outpin 0
 */

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 knob position.

  analogWrite(0, val);  // write the value to PWM output pin 0 (value in the range 0-1023)

  // 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, 1023-val);

  delay(100);           // wait 100ms for next reading
}
