Created
March 30, 2022 12:27
-
-
Save cmoz/121b98d3b3859b1f7fa7bf3da6561a46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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