Line sensor

On the cortex, does the line sensor go on the analog port or the digital port? And how to program it in easy c?

Go to analog port.

And when programming it… Do i write like this…

If ( line_sensor == ?? )
{

}

What values go in where the question mark is??

Figure it out… Read the sensor value on a line and then off a line and figure out a threshold. It varies from setup to setup, but is usually around the 700 range.

To figure out the threshold, take the line value and the non line value, and calculate the average.

For this you would use something like this (obviously not in any code):

if (LineTracker > 700)
{
Do something (Let’s call it task A)
}

else
{
Do something (This one is task B)
}


To make it more accurate, you might want to widen your thresholds, or in other words have a dead zone. This is so that if the lighting is a bit different or you are close to the threshold there is less risk of error.

To do this you need a light value and a dark value. Let’s say the threshold is 700, you can widen it by, let’s say, 50 on each value. This makes your thesholds 650 and 750.

In non-code type code, it would be something like:

if (LineTracker > 750)
{
Task A
}

if (Line Tracker < 650)
{
Task B
}

This way you have a dead zone of 100.

Thank you… I appreciate the help provided.