There is a rule in the world of programming: "Duplication should be removed"
There are different tools for removing duplication and one of the most basic ones is the Loop. Today we would focus on the Loop
There is a rule in the world of programming: "Duplication should be removed"
There are different tools for removing duplication and one of the most basic ones is the Loop. Today we would focus on the Loop
Usually, the robots we make have to perform one and the same movement or a series of movements over and over again.
For example: we want the robot to move in a square. How can we achieve that? We will put a block for forward movement, then a block for a 90 degree turn and then we will repeat this string three more times. In the end we will have a program with eight blocks. What if we want to make the robot move in a square 100 times, what kind of program will we build – having 800 blocks? Of course not – we will just set the two blocks (the block for forward movement and the turn block) to repeat 400 times.
How can we do that? When we need to repeat actions in programming, we use loops.
You can take the loop block (cycle) in EV3 from the orange Flow control palette as shown below:
We insert the blocks we want to repeat in the loop block.
For example, if we want to have an infinite forward-backward movement, the program will have the following structure:
The loop cycle is by default infinite but in most of our programs, we won’t need an infinite repetition. Let’s take for example the square-movement task – we have to repeat the forward movement block and the turn block four times only. If we want to make a hexagon, we will have to repeat the block six times.
To make the loop repeat a set number of times, click on the infinity symbol (the horizontal 8). Then choose the option Count and write how many times you want it to repeat. Loops have many other conditions for breaking, which we will cover in other lessons.
This Tutorial is used in the following courses and lessons
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.
Let's review the LEGO Mindstorms EV3 Intelligent Brick
The EV3 brick is the main computer of your LEGO robot and it has a display, a few buttons and various ports.
The first level of the Robotics with LEGO curriculum for students in fifth to twelfth grades.
Various constructions with robots are built. Learn how to control the motors so that the robot navigates around the Moon and Earth in various ways. Getting to know the first two sensors. The robot can feel its surroundings with the help of the Touch sensor and avoid obstacles.
The Ultrasonic distance sensor can help the robot avoid obstacles. Students work with concepts like loop, degrees and medium motor. Robots can now do two different actions at the same time - while solving missions on a field, the third motor clears detected obstacles.
In the next lesson we usually do a graduation. Write down your impressions about the students and the reasons why they have the grades you gave them.
The absolute starter. A new course book for students that are first grade (7-8 year old). If a student is to young to join the 8-10 years curriculum this is the place where he/she should start.
The course book contains a number of well structured 2-hourse classes for the youngest students that we've ever managed to productively include in a LEGO Mindstorms EV3 Robotics courses, groups and classes.
(Course book available only in Bulgarian and will soon be translated)
The second level of the Robotics with LEGO curriculum for students in second, third or fourth grades.
A new sensor is introduced - the Ultrasonic distance sensor can help the robot avoid obstacles. Students work with new concepts like loop, degrees and medium motor. Robots can now do two different actions at the same time - while solving missions on a field, the third motor clears detected obstacles. The first robot with chain-treads is built.
Today we will build our first robot for automated transportation which will help us learn a new block – the repetition instruction.