Hello Arduino community! I’m a Junior in high school, working on a project for a local science fair. I’m using an Arduino UNO (I’ll switch to a Lilypad later) to read values from a flex sensor. I am using this code:
int flexSensorPin = A0; //analog pin 0
void setup(){
Serial.begin(9600);
}
void loop(){
int flexSensorReading = analogRead(flexSensorPin);
Serial.println(flexSensorReading);
int flex0to100 = map(flexSensorReading, 0, 506, 110, 0);
Serial.println(flex0to100);
delay(250); //just here to slow down the output for easier reading
}
I’m hoping to have the values printed by the serial monitor as parts of 100 or less, so that I can calculate the percentage of flexion from that maximum value. So far, I’m getting two alternate numbers: one changing number that is over 100, and one changing number that is under 100. I would like to display only the value less than 100, but I am unsure of how to change the code in order for that to happen. I would appreciate any and all advice you can offer me.
EDIT: I have attached a picture of my SerialMonitor display.