- :-

Program Review: Random Distance

  • The program shown below is sample code for making your robot move for a random distance.
Hover on any block in the program to view a detailed explanation.
Random Block Numeric Generates a random number between 1 and 100. Sends the number out through the wire on its 'Value' terminal () plug. Sends a randomly generated number to the Move Block's 'Rotations' terminal () plug.
Move Steering Block On for Rotations Moves the robot forward at 50% power for the number of rotations wired into the 'Rotations' terminal () plug. Moves forward for a random number of rotations.

Program Review: Dangerous Wall

  • The program shown below is sample code for the mini-challenge.
Hover on any block in the program to view a detailed explanation.
Loop Block Ultrasonic Sensor > Compare > Distance Centimeters Conditionally sends the program flow back to the start of the loop. Lets the flow out of the loop when the Ultrasonic Sensor's value is less than '20'. Robot repeats movements inside the loop until the Ultrasonic Sensor sees an object within 20 centimeters.
Ultrasonic Sensor Block Measure - Distance Centimeters Reads the Ultrasonic Sensor in centimeters. Sends the sensor reading out through the wire on its 'Distance in Centimeters' terminal () plug. Sends the centimeter value read from the sensor to Move Block's 'Power' terminal () plug.
Move Steering Block On Moves the robot forward at the amount of power wired into the 'Power' terminal() plug. Start the motors on to move foward using the value from Ultrasonic Sensor as power level.
Sound Block Play file Plays the sound file named 'Stop' when the program flow exits the loop. Robot says "Stop!" when the robot has reached within 20 cm from the wall.

Program Review: Multiple Lines Display

  • The program shown below is sample code displaying text on multiple lines.
Hover on any block in the program to view a detailed explanation.
Display Block Text - Pixels Clears the screen, then writes the text "Rotation B: " at coordinate (10, 20) of the EV3 screen. Writes "Rotation B: " in the top left corner of the EV3 screen.
Motor Rotation Sensor Block Measure - Rotations Reads the Motor (B) Rotation Sensor's number of rotations. Sends the sensor reading out through the wire on its 'Rotations' terminal () plug. Sends the number of rotation from Motor B from the sensor to Display Block's 'Text' terminal() plug.
Display Block Text - Pixels Without clearing the screen, writes the value wired into the 'Text' terminal () plug at coordinate (100, 20) of the EV3 screen. Writes the number of Motor B wheel rotation next to "Rotation B: " on the screen.
Display Block Text - Pixels Without clearing the screen, then writes the text "Rotation C: " at coordinate (10, 50) of the EV3 screen. Writes "Rotation C: ", below "Rotation B: ", on the EV3 screen.
Motor Rotation Sensor Block Measure - Rotations Reads the Motor (C) Rotation Sensor's number of rotations. Sends the sensor reading out through the wire on its 'Rotations' terminal () plug. Sends the number of rotation from Motor C from the sensor to Display Block's 'Text' terminal() plug.
Display Block Text - Pixels Without clearing the screen, writes the value wired into the 'Text' terminal () plug at coordinate (100, 50) of the EV3 screen. Writes the number of Motor C wheel rotation next to "Rotation C: " on the screen.
Display Block Text - Pixels Without clearing the screen, then writes the text "Ultrasonic : cm" at coordinate (10, 80) of the EV3 screen. Writes "Ultrasonic : cm" onto the bottom left corner of the EV3 screen.
Ultrasonic Sensor Block Measure - Distance Centimeters Reads the Ultrasonic Sensor in centimeters. Sends the sensor reading out through the wire on its 'Distance in Centimeters' terminal () plug. Sends the centimeter value read from the sensor to Display Block's 'Text' () plug.
Display Block Text - Pixels Without clearing the screen, writes the value wired into the 'Text' terminal () plug at coordinate (110, 80) of the EV3 screen. Writes the value of Ultrasonic Sensor between "Ultrasonic : " and "cm" on the screen.
Wait Block Time Indicator Stops the program from processing additional commands until 5 seconds have passed. Robot displays the information written on its screen for 5 seconds.

Program Review: Display Rotation in Centimeters

  • The program shown below is sample code for making your robot display the wheel rotation in centimeters.
Hover on any block in the program to view a detailed explanation.
Wait Block Time Indicator Stops the program from processing additional commands until 3 seconds have passed. Robot does nothing for 3 seconds so that user can manipulate the wheel rotation manually to create Motor Rotation Sensor inputs.
Display Block Text - Pixels Clears the screen, then writes the text "Rotation B: " at coordinate (10, 20) of the EV3 screen. Writes "Rotation B: " onto the top left corner of the EV3 screen.
Motor Rotation Sensor Block Measure - Rotations Reads the Motor (B) Rotation Sensor's number of rotation. Sends the sensor reading out through the wire on its 'Rotations' terminal () plug. Sends the number of rotation from Motor B from the sensor to Math Block's 'a' terminal () plug.
Math Block Multiply Performs calculation, 'a' times 'b', where 'a' is wired in, and 'b' is set to 17. Sends the result out through the wire on its '=' terminal plug. Takes number of rotation from Motor B and multiplies it by 17. Sends the result to Display Block's 'Text' terminal () plug.
Display Block Text - Pixels Without clearing the screen, writes the value wired into the 'Text' terminal () plug at coordinate (100, 20) of the EV3 screen. Writes the number of Motor B rotation converted to centimeters next to "Rotation B: " on the screen.
Display Block Text - Pixels Without clearing the screen, writes the text "Rotation C: " at coordinate (10, 50) of the EV3 screen. Writes "Rotation C: ", below "Rotation B: " on the EV3 screen.
Motor Rotation Sensor Block Measure - Rotations Reads the Motor (C) Rotation Sensor's number of rotation. Sends the sensor reading out through the wire on its 'Rotations' terminal () plug. Sends the number of rotation from Motor C from the sensor to Math Block's 'a' terminal () plug.
Math Block Multiply Performs calculation, 'a' times 'b', where 'a' is wired in, and 'b' is set to 17. Sends the result out through the wire on its '=' terminal plug. Takes number of rotation from Motor C and multiplies it by 17. Sends the result to Display Block's 'Text' terminal () plug.
Display Block Text - Pixels Without clearing the screen, writes the value wired into the 'Text' terminal () plug at coordinate (100, 50) of the EV3 screen. Writes the number of Motor C rotation converted to centimeters next to "Rotation C: " on the screen.
Wait Block Time Indicator Stops the program from processing additional commands until 5 seconds have passed. Robot displays the information written on its screen for 5 seconds.

Program Review: Move for Centimeters My Block

  • The program shown below is sample code for using a My Block that takes an input number as centimeters, convert it into a number of rotations, and use it to drive the robot forward.
Hover on any block in the program to view a detailed explanation.
My Block Connector Block for My Block 'MoveForCM' Outputs the value wired into My Block named 'MoveForCM' placed in 'MoveForCM_main.evp3'. Sends the user specified constant value to Math Block's 'a' terminal () plug.
Math Block Divide Performs calculation, 'a' divided by 'b', where 'a' is wired in, and 'b' is set to 17. Sends the result out through the wire on its '=' terminal. Takes the number of desired Centimeters (from the Constant Block) and converts it into number of wheel rotations by dividing it by 17. Sends the result to Move Block's 'Rotation terminal () plug.
Move Steering Block On for Rotations Moves the robot forward at 50% power for the number of rotations wired in into the 'Rotations' terminal () plug. Moves forward for a number of rotations calculated from user specified centimeters.

Program Review: Obstacle Detection Until Black Line

  • The program shown below is sample code for mini-challenge in the "Obstacle Detection" lesson.
Hover on any block in the program to view a detailed explanation.
Move Steering Block On Turns Motors B+C On at 50% Power Starts moving the robot forward, into the cave. Another Move or Motor command will need to stop them later.
Wait Block Color Sensor - Compare - Color Stops the program from processing additional commands until the Color Sensor value is '1' (color black) Robot waits until the Color Sensor sees the color Black on the floor of the cave before continuing the program.
Motor Rotation Sensor Block Measure - Rotations Reads the Motor (B) Rotation Sensor's number of rotation. Sends the sensor reading out through the wire on its 'Rotations' terminal () plug. Sends the number of rotations to Variable Block, to store how far the robot has traveled to find the black line.
Variable Block Write - Numeric Stores the value wiring in into its variable plug as a variable named 'DistanceToLine' Stores the number of rotations required to reach the black line as a variable
Variable Block Read - Numeric Reads the value stored in the variable 'DistanceToLine', which represents the number of wheel rotations needed to reach the black line. Sends that value from its 'Value' output into the Move Steering Block's 'Rotation' terminal () plug.
Move Steering Block On for Rotations Moves the robot backward at 50% power for the number of rotations wired in into the 'Rotations' terminal () plug. Moves backward, out of the cave, using the same number of rotations to get the robot into the cave.
Variable Block Read - Numeric Outputs the value stored in the variable named 'DistanceToLine' 'Reads' or sends the number of rotations required to reach the black line to Display Block's 'Text' terminal () plug.
Display Block Text - Pixels Writes the value wiring into the 'Text' terminal () plug at coordinate (0, 0) of the EV3 screen. Displays the number of wheel rotation the robot used to find the black line inside the cave.