Stretch Sensor

Conductive Rubber Cord (Stretch Sensor)

Similar to a thermistor, the program measures the analog voltage and converts that back to resistance. When stretched, resistance is detected and the conductive rubber cord lights an LED.

stretchsensor-640x463

// Sensor pin - GND
// Sensor pin - Analog In 0, with 10K resistor to +5V
int LedPin = 13;    // LED connected to analog pin 13
int SensorPin = A0;    // Sensor connected to analog pin A0
 
 
void setup()
{
    // initialize serial communications
    Serial.begin(9600); 
}
 
void loop()
{
    // read the voltage from the voltage divider (sensor plus resistor)
    int sensor = analogRead(SensorPin);
    
    /*
    analog range to output
    map(value, fromLow, fromHigh, toLow, toHigh)
    value: the number to map
    fromLow: the lower bound of the value's current range
    fromHigh: the upper bound of the value's current range
    toLow: the lower bound of the value's target range
    toHigh: the upper bound of the value's target range
    */
    
    int output = map(sensor, 30, 70, 0, 255);
    
    // print out the result
    Serial.print("analog input: ");
    Serial.print(sensor,DEC);
    Serial.print(" output: ");
    Serial.println(output,DEC);
    
    analogWrite(LedPin, output);    
 
    // pause before taking the next reading
    delay(100); 
}

Conductive Rubber Cord from Adafruit

20140829_144512

20140829_144254

20140829_144531

Scroll to Top