Skip to content

Instantly share code, notes, and snippets.

@cmoz
Created March 30, 2022 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmoz/121b98d3b3859b1f7fa7bf3da6561a46 to your computer and use it in GitHub Desktop.
Save cmoz/121b98d3b3859b1f7fa7bf3da6561a46 to your computer and use it in GitHub Desktop.
#define MYRESISTOR 10000
#define STRETCHPIN A0
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
float reading;
reading = analogRead(STRETCHPIN);
reading = (1023 / reading) - 1;
reading = MYRESISTOR / reading;
Serial.print("Resistance ");
Serial.println(reading);
if (reading > 4700) {
Serial.println(" No stretch");
} else if (reading < 4000) {
Serial.println(" stretch");
} else {
Serial.println(" relaxed");
}
delay(200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment