Use the color sensor to count the lines and stop on the third line. We do not use the wait block for this.
- #149
- 24 Oct 2015
- 7:06
The algorithm is simple. Just detect a sequence of blacks and whites and in this way count the lines. Without the wait block we do not depend on rotations or seconds and thus we do not depend on the size of the wheels. on the robot constructions and other. This program could work for any robot.
Previous tutorials
English
Previously we did stop at the second line using a hack with the wait block. Now we would like first to remove the hack and second to stop at the third black line.
What should actually happen here is not to move forward, detect a line, stop, move forward, wait for a couple of ms, until we are no longer on the black line and then start detecting the black line. This logic is flawed and we must find another logic for our program. What would be the logic?
Again, detecting a line. Move forward, detect a line, stop, then we'll move forward with the Tank block, just on, but we are moving forward until we detect the white table. So it's a color sensor and we are waiting for a color and this color must be white, it should not be a black color, it should be a white color because the table is white. After we detect white this means that the sensor is no longer on the black line and we can stop with the Tank block. Like this.
This will move the robot over the black line and then over the table. The next step is to start looking for the second line. So we'll take this 3 blocks, we'll copy them
we have the same 3 blocks and we'll do the same program again. Like this. Just connect them.
This will move the robot to the second black line. Then after detecting the second black line, again I'll copy and paste these 3 blocks we'll move the sensor over the table after the second black line. We'll repeat this for the third line, copy and paste.
Running.
That's strange. The program should be working. It seems logical, but it's not actually working.
So you saw that it seems to detect some of the black lines but not all of them.
I'll need to get back to the computer so that we can explore what might be wrong with this program.
The logic of the program is working, but some of the values of the program are not correct. Now we didn't said much about the way the color sensor works, we just chose some values here. So for black it was 1 and we decided that for white it would be 6 and we are here waiting for the white table, but it seems that the table is not actually white and the sensor detects a table not white, it is not white it's kind of yellowish, very bright yellow, but it's not white, so if we are now over the black line you can see
right here in the lower right corner that when we are over black, so the sensor is over the black line, the sensor returns a value of 1 so it is OK we know that 1 is equal to black but if I now move the robot over the table you can see that the value is actually 7. This means that the sensor detects a color, this color is the color of the table and for this color it returns a number 7 and what we've done in all the blocks that we are waiting for the table is to select a color that is equal to 6. Now in the next videos I'll enter in more details about how are these colors formed and what does it mean to have a certain color and how are the values related to each other, but for now let's just select 7 here as a color that we are waiting not 6 because the table is not white but actually 7 and for the third block - 7.
What we had here as a program is that we haven't configured the correct value for the colors that we are waiting, for our robot to detect. Let's check if this program is working. Download and run our program.
And we have implemented a program that stops the robot at the third black line.
What I would like to do next is to improve this program because truthfully it's kind of ugly.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons
EV3 Basic Course. Introduction to robot programming, construction and sensor use
This course is designed for students, mentors and teachers that are completely new to LEGO Mindstorms EV3 robots and would like to start using them to learn, in classes or at competitions. It is quite different from previously built resources at FLLCasts because it makes no assumption on any previous knowledge and tries to introduce everything step-by-step.
- 38
- 193:26
- 30
Color Sensor
Very simple and basic introduction to the color sensor in the LEGO Mindstorms EV3 set. The first program is to stop at a line. Then we can move from stoping at line to counting lines and even more complex tasks.
- 8
- 0
- 3
- 3d_rotation 0
Instructors Remote Training
If you are working with students and you want to introduce Robotics to your class or you want to mentor a FLL team, but you are insecure about your technical knowledge in the Robotics field, then this is the right place for you. Having in mind teachers' busy schedule, we have design two different schedules and added an option to design one just for you. FLLCasts's Mindstorms EV3 Robotics Online Training is the perfect match for any teacher.
After the completion of each task the participant has to upload his solution for verification.
- 136
- 280:11
- 156
Color Sensor Theory and Practice
Very simple and basic introduction to the color sensor in the LEGO Mindstorms EV3 set. The first program is to stop at a line. Then we can move from stoping at line to counting lines and even more complex tasks.
- 5
- 0
- 0
- 3d_rotation 0
Instructors Remote Training
If you are working with students and you want to introduce Robotics to your class or you want to mentor a FLL team, but you are insecure about your technical knowledge in the Robotics field, then this is the right place for you. Having in mind teachers' busy schedule, we have design two different schedules and added an option to design one just for you. FLLCasts's Mindstorms EV3 Robotics Online Training is the perfect match for any teacher.
After the completion of each task the participant has to upload his solution for verification.
- 136
- 280:11
- 156
Color Sensor
What is color?
If I ask you what the color of the ball on the picture below is, you will surely answer red without hesitation. All of you know what is meant when we talk about the color of an object, but what is actually color? This is one of the most natural concepts whose meaning and origin people often fail to realize.
- 9
- 0
- 4
- 3d_rotation 0