Mindstorm is the software that we use to program the Lego robots. This is a graphical programming language based on the professional software called LabVIEW.
Projects: When you create a new project in Mindstorm, the default name is "project" and it will contain one program called "program". The project name is the name of the file that is saved. To change the project name use the SAVE AS command under the FILE pull down menu. Each project can contain many programs.
Programs: There can be many programs within a project file. Each program should be given a descriptive name so that it is easy to select the one you want to open or run. Once downloaded to the EV3 brick, the project becomes the folder name and the program becomes the file name that you will select in order to run the program. Every program begins at the START function and then will execute the following functions in order. The program will stop when it runs out of functions to execute, it reaches a STOP function, or you press the back button on the EV3 brick.
Functions: These are preset commands that have been created for you to use to create your programs. When you have opened a project, all functions are available from one of the tabs at the bottom of the Mindstorm software window. They are divided up among several colored tabs. Many functions have options you can choose from and variables that you can adjust or type in. Functions can be connected together by placing then right next to each other or by connecting them with wires.
Options: Many functions have options for you to choose from. There will be a default option selected when you drag the function into the program. You can click on the option to see the other possible options you can choose from. Changing the selected option may provide or take away variable that can also be changed to specify the specific behavior you are looking for. Some functions, like DISPLAY and MOTOR, their is a second options block in the upper right corner of the function that can also be changed to change the output of the function.
Variables: Many functions have variables that you can change to modify the behavior of the robot. Most variables are numbers but sometimes it may be a check mark, symbols or letters. Some variable will give you a menu of values you can choose, while others provide a slider that you can drag to change the value up or down. There will be a default value for each variable when you drag the function into the program. Make sure you check to see that each variable is set to the correct value in order to achieve the behavior you want from the robot.
Loops: This is a structure function within Mindstorm that allows you to have functions within it to be run more than once. A loop is equivalent to a FOR or WHILE command in other programming languages. Drag the functions you want to repeat inside of the loop command. Choose the option to set what conditions will determine how many time the functions repeat, or to determine the exit conditions that will allow it to stop repeating. For example, you could choose to repeat for set number of times and then you will change the variable to state exactly how many times you want it to repeat. Other options allow you to have it repeat until a sensor returns a specific value. The default option if for the loop to repeat infinitely which means it will not stop repeating until you end the program.
Switches: This is a structure function within Mindstorm that allows you to have the program decide what to do next. A switch is the equivalent to an IF or IF/THEN command in other programming languages. Choose the option to set set what conditions will determine how the switch will make the decision of what to do next. For example, you can have it perform one task when a button is pushed and a different behavior when the button is not pushed. Typically, you will place the functions you want to be performed when the conditions are met in the top section of the switch and the functions you want to be performed when the condition is not met in the bottom section of the switch. Switches can also make decisions based on time, sensor data, or the comparison of two numbers.
Blocks: You can define a new function by using "My Block Builder" under the Tools menu. First you create the program of what you want the block to do, by dragging functions into the program, connecting them, selecting options, and setting variables. Once it is correct, select all of the functions you want to include in the block and choose My Block Builder. You will then need to give your block a name, choose a graphic to go on the block, and write a description of what it does. More complex blocks may have variables that you can use to determine how the block will run. Add the variable in My Block Builder and then go back into the program and use wires to connect the variable to the functions you want it to modify. Once the block is created, it will appear in the teal menu at the bottom of the project.
Comments: It is good to get in the habit of writing comments into your program to explain what each part of the program does. Loop functions allow you to give the loop a name, which can help to identify what is happening inside it. Other time you will need to use a comment box to type out a description. Comments can be very useful way to remind yourself what the program is supposed to do, but more importantly it helps other people understand your program. This is important when you are creating a program that will be used by many people or working on a larger project and several people are working together to program it.