
This is a program I made to try and show some kids at the school I teach at how to use variables to control and compare functions and I can't work out why it's not working. I wanted it to follow a black line using a colour sensor as a light sensor, which it does. There are three colour sensors mounted along the front; one colour sensor made to work as a light sensor flanked by two colour sensors on either side. The colour sensors on each side are to detect green in the form of navigation cues (4ox40mm green square in the vertices of the black lines) and a large green tile known as the chemical spill in the Robocup tournaments. I'm trying ot get it to detect green on either the left or right side and exucte a motor function when it does. I tried to get each colour sensor to assign a variable to the colour detected (between 1-6 with green being 3) and then ask the true/false question whether the variable was equal to 3 and if it was write a new variable (cs3 and cs4) to be sued at close the loop at the end if cs4=cs3. The robot just makes one turn then stops and I can't work out why as it seems to make sense to me. If anyone has any advice as to how to make this work I'd be very grateful to hear them.
Regards,
Simon