Created
April 11, 2018 10:50
-
-
Save arduinothai/9eb6cee8ebfd2782a555bbedc75193d2 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
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