Suggestion on how to follow line with different colors

hi everyone

i have a line-following car, which has a color sensor in the middle and 2 line-following sensors on the sides.

i have a track with colored parts which i tried to pass for a 2 weeks now with no luck,

Q/ what is your advice on number of sensors and programming approach.

my biggest challeng is the big track where in each turn both sensors read the black track and stuck
black line width is 8 cm , each color block is 8 cm * 9 cm.

Red: make 360 turn
blue: stop for 10 sec
yellow: stop for 15
green : start and end

The three-sensor configuration you describe should work well to navigate the track, if you can keep the color sensor reasonably well centered over the line. But five sensors would work better.

Get the centering to work first, for a straight portion of the track, and make sure that you can detect the color changes.

When that works well, then start to work on navigating the turns.

How would you do that? Keep the main color sensor entered on the line?

All three (or more) sensors are used to estimate the line position.

Most people use a weighted average, after subtracting the previously measured background, as described in this paper (and many others): https://www.emo.org.tr/ekler/715e50cd216c231_ek.pdf

The problem is , if I programmed the Arduino to make small turns when it leaves the track (with a straight line), i can't keep up with the big turns and the car leaves the track eventually

The robot is going too fast for your current algorithm, or it is simply wrong.

Plenty of line follower code is posted on line, so take the time to study what other people have done, and make sure you understand the details.

You have at least 2 types of turns. Micro turns and Macro turns. The default could be micro turns with a look ahead sensor(s). The look ahead sesnor(s) could alert to an upcoming macro turn. Then the program could possibly handle those 2 different situations.

I built a Hexadpod using 2 ESP32 WROVERS and 1 ESP32 WROOM. I was amazed at the number of things that needed to be done for the hexapod to be able to roam around a place on its own. I learned a lot.

thanks for your kind responses, yes i found some code posted online and i did similar cars in the past but most were small tracks with less than 3 cm width. but i will take my time to analyze the code

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.