| Stretch light by Karmen Franinovic <http://people.interaction-ivrea.it/k.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 Created 15 May 2004 Revised 26 January 2008 |

    // Stretch light
    // by Karmen Franinovic <http://people.interaction-ivrea.it/k.franinovic>

    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
    }

|  | Circuit schematics: the LED is connected to Wiring PWM pin 0. The stretch sensor is connected to Wiring analog input pin 0.