HELP! Line Follower

Hello, I have been trying to program a marble sorter. We are trying to set the line follower to detect three different types of variables, but I’ve only been able to set two. I was wondering how to set a range of values. Instead of like [linef]>3000, I wanted it to be, [linef]>3000-3100. This is my code. PLEASE HELP!
Capture.PNG

Try this as the condition in your if statements instead of what you have now.


if(SensorValue[lineF] > bottomRange && SensorValue[lineF] < topRange) {
  doSomething();

Replace bottomRange with the lower limit of your target area and topRange with the upper limit.

If you want them to have a value of between 3000 and 3100, you need to have a separate condition for each bounding value and join them together with an AND operator (&&). It’d look like this:

if (SensorValue[lineF] < 3100 && SensorValue[lineF] > 3000)
{
(Whatever you do here)
}