Black Line Detection Problem

I’m programming my VexIQ clawbot with ModKit. I’d like have it programmed so that when the color sensor detects a black line, it reverses. I used two scripts which are below. To detect the darkness I decided to use the greyscale % setting of the color sensor. I’ve attached pictures of the two scripts below. The problem is that:

With the script that uses the “=” sign I can’t be sure exactly what percent the dark line is at given that the shade changes from one part of the black line to the other because of lighting. So the “else” part responds but the rest of the script doesn’t. But given that the percent has the to be a specific amount can make it challenging to program… So I also tried the less than script.

When I tried the “<” script I get a message saying something along the lines of color not defined. I forgot the exact wording as I don’t have the robot here with me at the moment and it also told me to contact ModKit staff, but I’m hoping someone here has an answer in case there’s something wrong with the logic of how the program is put together.

Please respond as soon as possible, I hope to be able to teach the solution to a bunch of kids this Saturday.

Thanks

Capture.PNG

Capture1.PNG

Bummer, I wrote a load of text as well and it didn’t post!
I think you are encountering 2 separate problems here. The first is a bug in Modkit which is causing the Color not defined error message. If you go to the Robot setup screen and change your colour sensor to 3 colour, then back to greyscale again, all should be well.
I think the wait 1 second in you code is causing you an issue - the robot can pass over the line during the wait period and miss the line altogether. Also, try having the control code under the Brain and use broadcast commands to tell the motors what to do.
In my example above, I have a piece of code under each motor for forwards and backwards (as well as setting the motors to 50% velocity as well)