Hello All
Im working with a stretch sensor here and im trying to attach a percentage value to the analog value. I have done this (only part of the code). the problem im having is it will print all of the values 10%-100% rather than only printing the current value. I know that i need to create a range or some type only i forget what that is called in computer language... basically i need to create
if(sensorValue >800 but below 804) than print out 0%, and so forth for the rest 10%-100%. i need to put this into all of my if statements so they are no longer true.
any thoughts on the best way to do this?
{
if(sensorValue>800){ //You can change the number here to adjust the threshold.
Serial.print("Straight - 0%");
}
//10
if(sensorValue>805){ //You can change the number here to adjust the threshold.
Serial.print("Straight - 10%");
}
//20
if(sensorValue>810){ //You can change the number here to adjust the threshold.
Serial.print("20%");
}
//30
if(sensorValue>815){ //You can change the number here to adjust the threshold.
Serial.print("30%");
}
//40
if(sensorValue>820){ //You can change the number here to adjust the threshold.
Serial.print("40%");
}
//50
if(sensorValue>825){ //You can change the number here to adjust the threshold.
Serial.print("50%");
}
//60
if(sensorValue>830){ //You can change the number here to adjust the threshold.
Serial.print("60%");
}
//70
if(sensorValue>835){ //You can change the number here to adjust the threshold.
Serial.print("70%");
}
//80
if(sensorValue>840){ //You can change the number here to adjust the threshold.
Serial.print("80%");
}
//90
if(sensorValue>845){ //You can change the number here to adjust the threshold.
Serial.print("90%");
}
//100
if(sensorValue>850){ //You can change the number here to adjust the threshold.
Serial.print("100%");
}
Thank you for your time.