**#224**- 14 Aug 2016
- 5:43

Program

### English

- The next part or our program is after we have arrived at the fourth line, then to take the order of the blocks. We have programmed the order of the blocks and we have stored this in one of the arrays. And now we must move from the fourth line back, put the green block. Move forward then return three lines, put the green block. Then put the blue one, the red one, and the blue one. So this is the subject of today's video.

For sorting the different blocks, we have two blocks. The first one is Find places and the second one is Sort Blocks, and this is in our main program. This here is the main program. And we'll now enter into the Sort Places. This is the block that actually sorts the different blocks in the different regions. And the idea of this block is very, very simple. We have an array, an array of values. And this array of values, it's called places, and there are five values in this array. So we have five different cells, one, two, three, four, and five. And we have different values in these boxes. The first one, it is green, the first one is three; let's say the second one, let's say is three, then two, again two and one. And we have different lines. And we move on these different lines and throw them right here. This is the first line, second, third, and fourth. And now the robot moves in this direction. And as we move in this direction what we must do is the following, we arrive at the fourth line and we stay there. Then if the first element is three, we must count, one, two, three lines. Drop the block and return again one, two, three lines. The second element is again three and we move one, two, three lines. The third element is two and we're again on the fourth line. We move one line, two lines, we drop our block and then we return to initial position. And that's the idea of this block. And for this we use an array, and this array it's called "Places." Just draw this like this. Imagine that the array is just a number of values in an order. And we'll first use with the first value then we use the second value, the third, the fourth, and the fifth value. We have the places and this is the array. And we have this loop here. This is the loop that counts the line. And it's a pretty simple loop. We move back with the black line, we move back with the white and this means that we moved over one line. And we do this loop a number of times if the value of places is the current value of the first element places is three, we'll do this loop three times or if it's two then we'll do it two times, or one we'll just do it once. And after this loop, we do it one, two or three times, we stop and with Motor D we drop the block in the region. And then we must return the whole robot to the initial position. So we do the same loop again the same number of times but this time we move forward, not in reverse but forward. And that's the idea for the program and it's pretty simple to do it in this way. And we do this whole operation five times because we have five different blocks. Again initially we are at the first element of the array, and we take the value of the first element of the array with set places. And then the first value because it's the first direction of the loop. We move back the number of lines that is the value in places. We drop the block and then we move forward, again the same number of times and we do this five times. Now what's interesting about this program is how do we know the different value in places. And that's the tricky part and this is the subject of the next video where we'll take a look at the Find Places Block. Below the video we'll add a number of tasks along with this program so download it, try it, and try to solve the missions and accomplish the tasks.