- :-

Program Review: Infinite Square Lap

  • The program shown below is sample code for the Square Lap 1 mini-challenge in the "Looped Movement" lesson.
Hover on any block in the program to view a detailed explanation.
Loop Block Unlimited Always sends the program flow back to the start of the loop when the flow reaches the end of the loop. Robot repeats movements inside the loop forever.
Move Steering Block On for Rotations Moves the robot forward 1 rotation at 50% power. Robot drives forward
Move Steering Block On for Rotations Makes a point turn to the right, for 0.5 rotations which causes about 90 degrees of body turn) at 50% power. Turn the robot 90 degrees to the right

Program Review: One Square Lap

  • The program shown below is sample code for the Square Lap 2 mini-challenge in the "Loop with Count Control" lesson.
  • The code is very similar to the solution for Infinite Square Lap solution above,
    except that the loop is in Count Mode.
Hover on any block in the program to view a detailed explanation.
Loop Block loop for count Conditionally sends the program flow back to the start of the loop. Lets the flow out of loop after the 4th pass through the loop. Robot repeats movements inside the loop until they have been run 4 times.
Move Steering Block On for Rotations Moves the robot forward 1 rotation at 50% power. Robot drives forward
Move Steering Block On for Rotations Makes a point turn to the right, for 0.5 rotations which causes about 90 degrees of body turn) at 50% power. Turn the robot 90 degrees to the right

Program Review: Square Lap with Obstacles

  • The program shown below is sample code for the Square Lap 3 mini-challenge in the "Loop with Sensor Control" lesson.
  • The code is very similar to the solution for One Square Lap solution above,
    except that the loop is in Sensor Mode.
  • This is different from using a Ultrasonic Wait Block!
    • Wait Block holds program flow until a condition is met.
    • Loop with Sensor Control does NOT hold program flow. It only decides whether to send the flow back, or let it out of the loop. Because of this, the loop checks the sensor value just once, immediately after the last movement in the loop.
Hover on any block in the program to view a detailed explanation.
Loop Block Ultrasonic > Compare > Distance Centimeters Conditionally sends the program flow back to the start. Lets the flow out of loop if sensor's value is 'less than 30' at the end of the loop. Robot repeats movements inside the Loop unless the Ultrasonic Sensor sees an object within 30 cm at the exact moment the loop ends (just after turn completes).
Move Steering Block On for Rotations Moves the robot forward 1 rotation at 50% power. Robot drives forward
Move Steering Block On for Rotations Makes a point turn to the right, for 0.5 rotations which causes about 90 degrees of body turn) at 50% power. Turn the robot 90 degrees to the right