how to detect RBG color in motion?

Hello everyone, I'm doing a project on Traffic congestion using swarm robotics by arduino boards.

The 4 robots will be line following continuously and when ever the robots come to a junction, i'm implementing first come first serve logic. Wherein the robots communicate with one another and wait for the higher priority bot to pass the junction before it does.

I'm using RED, GREEN and BLUE colors to make the bots to stop at the junction.

The problem which i'm facing is, whenever the sensor(LDR with white LED) detects RED color the value is in 230-260 range(in ADC) which is fine and for Black it is in 640-675 range, but when the robot crosses the cross over track( LINE for following ) where there is transition from white to black, the RED color is being detected. :fearful: :fearful:

I don't want that to happen.

I have tried with averaging the samples to get the step response(white to black sudden transition) it worked but i expects a delay which I cant give since my project is in real time.

so can anyone tell me what to do now? How to detect the color in motion without any ambiguity?

This is how I want my project to be.

https://www.youtube.com/watch?v=TuMJbcp2tV0

In this video, they have implemented bar code kind of thing at the junction.

can anyone write the code for this using 3 to 4 IR sensor and ADC how to detect this bar code, where the sensors have to detect the bar code simultaneously ?

Please do respond to this post asap because my project deadline is here.

Regards.

Please don't post the same thing in numerous places; post 1 time and have some patience. Duplicate posts are being deleted.

How well does your sensor work with color? Are they distinctive enough?

Also, iirc LDRs react really slowly.

well since i'm using LDR sensor with analog circuit, the sampling speed is better than moderate.

Yes, it can distinguish between colors in static. But since i have mounted the sensor on the line follower, when the bot is in motion and crosses the white to black color it keeps picking RED color values since the RED color range falls between WHITE and BLACK. :cold_sweat: :astonished:

it keeps picking RED color values since the RED color range falls between WHITE and BLACK.

But, the red range does not fall in the white range or in the black range. So, you should be able to deal with white and black independent of red.

Posting your code would get this from the "well, that's a pity" stage to the "we can help" stage a whole lot sooner.

If you are not actually detecting color, then any color which is not as bright as white, and not as dark as black, is going to give you the same answer. They all look like gray.

My advice would be to get a colour detector gadget, or make your own by using several LDR's with bits of coloured cellophane stuck on top of them.