by gloomyandy » Sun Nov 21, 2010 12:42 pm
So you still have not told us what you have done to work out what is going wrong... Also just providing single word answers does not really help or make your problem very interesting to other people, if people are not interested they will not want to try and help you.
How have you checked that the Ultrasonic sensor works at distances of 5cm and less? How reliable are the results? Most people find that the Ultrasonic sensor does not work reliably at such short distances...
How have you checked that the color sensor works correctly at these distances. Again most people find that the color sensor is not reliable at distances greater than a couple of cm... Have you tried the sensor in different light conditions? Does it always work?
How are you testing your code? I assume there is more than just the lines you have posted here?
There is nothing obviously wrong with the code you have posted, so you need to investigate further....
So have you tried adding code into your program to find out what is going on? Try adding some display statements into your takeControl method, is it even being called? If it is being called, what values are returned by the Ultrasonic sensor?, what values are being returned by the color sensor?