Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Created April 11, 2018 10:50
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 arduinothai/9eb6cee8ebfd2782a555bbedc75193d2 to your computer and use it in GitHub Desktop.
Save arduinothai/9eb6cee8ebfd2782a555bbedc75193d2 to your computer and use it in GitHub Desktop.
int flexSensorPin = A0; //analog pin 0
void setup()
{
Serial.begin(9600);
}
void loop()
{
int flexSensorReading = analogRead(flexSensorPin);
Serial.println(flexSensorReading);
//In my tests I was getting a reading on the arduino between 512, and 614.
//Using map(), you can convert that to a larger range like 0-100.
int flex0to100 = map(flexSensorReading, 512, 614, 0, 100);
Serial.println(flex0to100);
delay(250); //just here to slow down the output for easier reading
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment