Count Lines. Move to 4-th Line. WRO Elementary 2013 Pro Preview

  • #223
  • 07 Aug 2016
  • 4:22

English

The block that we are about to see is about counting the lines and moving to the fourth line in the World Robotics Olympiad 2014 Elementary challenge.

You can find this program below the video in the materials section and it's the full program for solving this elementary challŠµnge. It starts of course with the menu that we looked at a few videos ago. And we reach at the point that we move to the fourth line. And we have a block that is called Move to fourth line. If we enter this block, we can see the actual code that counts the lines and moves the robot to the fourth line. Let's look at the code. We just zoom this. Counting the lines is not very difficult. We start two of the motors B and C and just start them for 2 rotations to move forward very fast and then we enter a loop. In this loop we start motors B and C for unlimited amount of time and rotations. Just on. And here the robot is just moving forward and it's waiting for something. This something is to detect with the colour sensor that we have reached a black line. And in our case a black line means that the sensor returns something smaller than 25. And this is black. On our field the value is actually 10, so something smaller than 25 is a black line. Then we continue moving forward. We don't stop the motors and we wait until we detect something that's white so that we pass the line. So we detect when we are on the line and we are on the line for a number of milliseconds and then we wait to move over the line and detect white. This means that we have moved over the line. Then we play a sound so that we can hear it and we can debug it and it's better in this way for the camera . We do this whole loop three times which means that we count three lines. And we can change here the number and we can count 1 line or 2 lines or 3 or even more lines. At the end when the loop finishes we stop the motors. So that we know where we are. And to reach the fourth line we do the same thing again but this time not using the reflected light but the colour detection of the colour sensor. We start the motors and we wait until the sensor on port number 3 detects something that is black. If I now open, we can see that 1 means black and when we detect black we stop with the motors. When we stop we return back a little until we detect white. 6 for the colur sensor means white. And in this way we are just before the last fourth line. And we are on a position where we can start our program for sorting the different blocks into different regions. So this is the program. Find it below the video. Especially this block. And do the tasks that are again described below the video. Let's see again how the robot behaves.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons