I see a few things that could be causing problems. This may be a good time for a quick lesson on wires & sensor blocks...
First, the sensor blocks all have conditions built-in to them. So you can use them to do a lot of your compare functions.
Next, wires can sort of act like variables, holding values until you need them.
Attached is a program that should function the same as yours (except that I don't have the color sensor blocks loaded on this computer, so I used light sensors instead). The True/False returned by the sensor block is transported in the wire, and in the end, compared.
Problem 1:If you're setting both C3 & C4 to zero, after it goes through the loop once, both values are equal, so the loop will exit. When that happens, the motors will run for a bit, then shut off.
Problem 2:With three switch blocks, you're telling the motors to do three different things. I would suggest making a simple truth table to determine what the motors should do in each of the eight possible cases, and possiblly use nested if statements, or a case statement
Sensor 1, Sensor 2, Sensor 3, Motor B, Motor C
Green, Green, xx, stop, stop
Green, Not-Green,xx , Turn Left?
Not Green, Green, xx, Turn Right?
Not Green, Not Green, Light, Turn Left?
Not Green, Not Green, Dark, Turn Right?
Be careful not to turn by driving B back, and C forward. The robot may never drive forward, if you do that. (but, you may want that when the sensors see green)
- (1.1 MiB) Downloaded 12 times
---> Link to lots of MINDSTORMS stuff under my picture --->