programming KOP line trackers

can any one please explain to me how to program the KOP line tracker in c++, or explain in full detail the example code which confused me alot. I do know that They are digital inputs, but im wondering if you have to use a specific “.h” in the file wpilib. to declare a line tracker variable, or DigitalInput, and what kind of data does it read and how to test it if it is working whether by using “printf” which never seems to print anything to the driverstation or something else. It is the first time my team is using one.

-thanks in advance :yikes:

I haven’t looked into the line trackers, so I can’t help you there, but I can help on the printf statement. It prints not to the driverstation, but to the target console. Normally, you won’t see this. To pull it up, go into windriver while connected to the robot, right click the VxWorks connection in the bottom left, and go to “Target Tools” -> “Target Console”*.

*May not be perfect. I don’t have windriver on this computer.

thanks man i have been looking all over for the target console, but one question, is there any way to slow down the way the target console reads the values?

:smiley: ::ouch:: :o ::safety:: :cool:

Nope, they’re just default DigitalInputs. You can use .Get() to get its status - 1 is tripped, 0 is not tripped. On carpet, though, you’ll have to do !sensor.Get(), because carpet’s dark and the lines are light.

Well, you could set up a counter so it only prints every tenth value it reads, or every hundredth or whatever.

How do i do that?

Something along the lines of this:

int count = 0;

   readInput(); //However you get the data

   if(count >= 10)
      count = 0;

To elaborate on what Demosthenes2k8 said, The values you get are dependent on a couple things. First, the sensor has two outputs, one is normally high, while the other is normally low. Depending on which wire you hooked up to your Digital Sidecar will affect what you read in the code. Also, the sensors have an adjustment knob on them. The sensors will most likely have to be calibrated to work on what ever test surface you are using. Just make sure it has a good contrast.