line follower with coloured obstacles

We´re a 16 years old students group. We want to resolve a LEGO trail with Arduino. We have a simply line follower with a tb6612fng, arduino uno and a qtra sensors array.

The trail is to follow the line until to find a object. If the object is black , the robot must catch it and return by the black line to the start, leave the line , turn left or right, release the object, and go for follow the line again....

If the object is white, the robot must catch the object, turn left or right, leave the line, release the object out of the line, return to the line, and follow the line again, until a new object.....

We need help, lol!

We are thinking about put a cny70 who read the object colour. We haven´t a better idea. Connect it to an analogic pin and distinguish between ambiental light, black object and white object.

For the sketch...we are thinking about to work with the sensors values from the qtra. Something like this:

if (sensorValues[1] < 750 && sensorValues[2] < 750 && sensorValues[3] > 750 && sensorValues[4] > 750 && sensorValues[5] < 750 && sensorValues[6] < 750 && cnsensor < 200)
{
Serial.print ("we are over the line and there is not any object ");
delay (2000);

goahead()

}

else if (sensorValues[1] < 750 && sensorValues[2] < 750 && sensorValues[3] > 750 && sensorValues[4] > 750 && sensorValues[5] < 750 && sensorValues[6] < 750 && 200 > cnsensor > 200)
{
Serial.print ("we are over the line and there is a black object ");
delay (2000);

catchit()
gobackward()
}

but I can get good results...

Can anyone help me please?

Thanks a lot!!

You can also (and better) answer me in Spanish

Hello, you can use cny70 to read black and white, but you should also use HC-SR04 to detect colission, otherwise your robot can crush the object. I'd start with the code once you figure out which sensors are definetly going to be used in the setup.


Hola, pueden usar el cny70 para leer blanco y negro, pero les recomiendo usar tambien el sensor ultrasonico HC-SR04 para detectar el objeto desde una distancia prudente, ya que de lo contrario podría chocar contra el objeto el robot dificultando su tarea. Les recomiendo realizar el código solo cuando hayan decidido que sensores y componentes irán en el robot.

Es una buena idea. Nuestro gran problema es el código, no sabemos pasar la estructura a código. La velocidad es importante, pero no imprescindible... Alguien nos podía ayudar con el código?

It is a good idea. Our big problem is the code, we don´t know translate the code structure. Speed is important, but not essential ... Someone could help us with the code?

Which is more reflective, black or white? Maybe check in IR as well as visible light.

A colored-bulb led can be used as a colored-light sensor but this is black and white legos, hello?

You might want an ultrasonic sensor to detect the object you want to measure the reflectivity of, a light sensor is not an eye or camera. Ultrasonic should 'see' legos.

White is more reflective... Is it possible to detect the diference between white objects, black objets, and no object (ambiental light) with a cn70?

thanks!!!

(can anyboy help us with the code?)

wow this project bring me back to my high school years,

well then, I would like to know a couple of thing... first what sensor do you have in your disposal, and lets talk about the layout of the field, is it white background? with black line? or much like that, all that play a vital role in make or brake the game,

disclamer:
used to represent for state in national, Begin programming for NXT and RCX but fall in love with arduino now.

Thanks!!!!! Black line over white background, qtr pololu for the follower and cn70 to distinguish black oblects and white objects

ouh cool.

When you say qtr polulu I'm assuming its this one?
Analog Sensor Array Polulu QTR

if so great.
Its should be noted that in the website there a resources page where by you could download a ready build QTR Arduino Library for your convenience (Link to GitHub Polulu QTR library). The resource page also indicate how to you this library in pdf format ( Arduino Library description PDF) please read through, if any problem or you don't understand post it here or PM me for direct question. In this library theres some serious Help for line following robot but i leave that for you to explore.

and when you say CNY70 I'm assuming its this one or something like it?
Vishay CNY70 Product

if so, in the same web page there is the data sheet, which you can download here (CNY70 Vishay Datasheet PDF ) and please also refer to its application note too (Vishay CNY70 Application Note). Since this does not have a complete circuit please refer to the picture below.

I think I have given enough info for you to start your project. If you still have any question, please ask in this tread or send me a PM for more direct question.

sorry this reply was too late, I wanted to send it yesterday, but i was sidetrack with something. Hope it still helps.

We have the line follower robot, we´re adapting an eye to detect black or white objects, and we need a good programmer! Thanks!!!!!

Hi, I'm working with him.
How can i make different "sections" in a program, let's say we have to follow a black line, if the "eye" detects black, it must go forward, but if it detects white, the robot must go right and move a can out of there.
BUT, how do I integrate that in the code? I only know how to move some motors and use sensors, but I would like to learn how to separate modules in a program.
I've heard something about the IF statement but it's a bit difficult to me to write all that code.
Do i have to use the IF statement?
Thanks, some help will be very appreciated.


How can i know the relative position, do I have to use encoders or an stepping motor to get to the line using trigonometry?
We are a lost here... hahaha
Can somebody give me a webpage to simulate arduino circuits, i've bought an arduino uno but it will arrive in the next two weeks so I'll like to do some little testings before! :slight_smile:
Thanks!

We think we must oreder differets actions(go forward, turn left...) depending de 6 array sensors an tuhe cn70 who recongnize tue object colour... But we can´t do it properly...

May we use "if else" conditions or "while" conditions? sensors value o position ?

Thanks