/** 
 * Stretch light
 * by Karmen Franinovic
 * 
 * Controls a light's intensity by pulling a stretch sensor (rubbery ruler).
 * The stretch sensor is made of conductive rubber, that changes 
 * resistance when it is streteched.
 * The stretch sensor is connected to analog input pin 0
 * The LED is connected to the analog output (PWM) pin 0
 */

int val; 

void setup()
{
  // nothing for setup
}

void loop() 
{
  val = analogRead(0);            // read analog input pin 0
  val = (val - 400);              // min value read from the stretch sensor was 400 
  val = constrain(val, 0, 1023);  // constrain value
  analogWrite(0,val);             // write value to PWM (analog) output 0
  delay(50);                      // wait 50ms for next reading
}

