Hi Im trying to use a 2" stretch sensor and have an serial printout of the distance stretched.
The problem is the value is coming in at around 10 and when i stretch the sensor it goes down to about 4.
im looking to have a larger range here and for the output data to go up when im stretching. Iv played around with the direction of the current and moving the resistor around as well as the location of the analog wire but nothing seems to work.
Here is my circuit.
And here is my code
/*
BODY Language:
Wearable Technology 2 (GDES 3B44)
Code taken and modified from:
Sensor Project
Wearable Technology 1 (GDES 3B16)
Kate Hartman - Fall 2010
Example: Using a Stretch sensor to sense whether you are resting or stretching you shoulder.
Attach the sensor to the back of a shirt
Attach an LED or a buzzer to pin 8.
*/
int ledPin = 13; // LED is connected to digital pin 8
int sensorPin = 0; // Stretch sensor is connected to analog pin 0
int sensorValue; // variable to store the value coming from the sensor
void setup()
{
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output
Serial.begin(9600); //initialize the serial port
}
void loop() // run over and over again
{
sensorValue = analogRead(sensorPin); // read the value from the sensor
if(sensorValue>850){ //You can change the number here to adjust the threshold.
Serial.print("Stretch");
digitalWrite(ledPin, HIGH); //Turn LED on
}
else{
Serial.println("Rest");
digitalWrite(ledPin, LOW); //Turn LED off
}
Serial.print(" Sensor Value: ");
Serial.println(sensorValue);
delay(100); // delay for 1/10 of a second
}