Course 2 / Lecture 2:

Saving and loading my project,
writing sequential programs

In this lecture you will learn how to save and load your code. You will learn how to write a sequential program. You will be able to play a melody on the brick's speaker and you will be able to display emotions using happy, sad or smiley faces. Plus you will also learn how to coordinate sounds with other tasks.

Figure 1 - The left column plays music while the right column displays emojis


Task #1:

Create a new project in SNAP!

Creating a new project in SNAP application is a really easy thing. Click on the grey document icon above the categories and select the 'New' option as you can see on Figure 2. You will see a pop-up window called 'New project'. The 'New project' window asks if you would like to replace the current project with a new one. If you do not save the current project, it will be disappear after you click on 'Yes'. So, if you sure about the new project then click on 'Yes'. If not, choose 'No' to return to the current one. You can also create a new project using a Ctrl+N hotkey on your keyboard.

Figure 2 - Creating a new project

Task #2:

Save your project in SNAP!

You have probably thought that some of the programs you have written earlier would be nice to store somewhere. There are two solutions to do this. One is to save it to your web browser and the other to export it as a snap file to your computer. Let's see the first way! Click on the grey document icon above the categories as you did earlier and select the 'Save' option from the list like Figure 3 shows. You will see a pop-up window called 'Save Project'. Here, you can name your project and save it by clicking the Save button. In this case the SNAP will save your project into the local storage of your web browser. So, the projects saved here will be lost if you clear your web browser's cookies and other site data. You can also save your project using the Ctrl+S hotkey.

Figure 3 - Saving project into the web browser's local storage

Task #3:

Load your previously saved project in SNAP!

You saved your project to the local storage of your web browser in the previous task. Let's see how you can load it. Click on the gray document icon again and select the 'Open...' option or press the Ctrl+O hotkey. You will see the 'Open Project' window where you can see all the previously saved projects. To open a project, select the required one then click on 'Open' (Figure 4). The selected project will be opened in SNAP and you will be able to run it or make changes on it. You can also has an option to delete the saved projects. If there is a program you would like to delete, just select it then press the 'Delete' button. Note that the program you deleted can not be restored after!

Figure 4 - Opening project

Task #4:

Export your project to your computer!

You learnt how you can save your project to your web browser's local storage. The another way of saving your project is to export it to your computer. To export the project, click on the document then select the 'Export project...' option as can be seen on Figure 5. Your web browser will download the exported project as a snap file into the folder you have set in your browser's settings. By deault, it is the Download folder of the logged-in user. If you check the bottom of your browser, you will find the downloaded file. Due to this, you can share your project with your friends.

Figure 5 - Exporting project

Task #5:

Import the previously exported project from your computer!

There is also the possibility to load the previously exported projects. You can do that by clicking on the gray document icon and selecting the 'Import...' option. The 'Open' window will show up where you need to browse the exported snap file you want to import as can bee seen on Figure 6. The selected file can be one of your exported project or one of your friend's exported project. Select the right one then press Open to load it. Now, you should see the imported program in the SNAP app.

Figure 6 - Importing project

Task #6:

What is the difference between saving and exporting project?

Please look at Figure 7! The main difference between saving and export project is the place where the project file will be located. If you click on the 'Save' option, the SNAP will save your project into your web browser's local storage. It is a quick and easy, but not the most safest way to save your projects because if you delete your web browser's cookies and local storage data, the projects you have saved here all of them will be lost. But if you export the project, you can select where you would like to store it as a snap file in your computer and you can import it at any time.

Figure 7 - The difference between saving and exporting project

Task #7:

Write program to show three emojis on the EV3 Brick's screen!

In this task, you need to create a simple program. The program should show a happy face, then a neutral face and then a sad face on the Brick's LCD screen after each other. First, you need an entry point. To create it, please use the 'when green flag clicked' block from Control category. To display the emojis, you need to use the 'Display [smile] on LCD' blocks belonged to the Lego category. Finally, you should place 'wait [time] sec' blocks between the 'Display' blocks like on Figure 8. Without 'wait' blocks, the faces would change too fast, so you would not be able to see them clearly. The 'wait' blocks ensure you to be one second between them. Start the program to try it!

Figure 8 - Program to show faces

Task #8:

Write program to play the Entertainer from Scott Joplin using the Brick's speaker!

Now, you need to write a program that plays the Entertainer from Scott Joplin through the Lego EV3 Brick's speaker. You should find a 'Play [note] note for [time] ms' block in the 'Lego' category. Using this block, you can set a note and its duration in milliseconds you would like to hear. Please download and open the sheet music of the song. After that, you can easily set the right notes for the blocks. If you have built the program, click on the green flag icon to hear that nice song immediately!

Figure 9 - Program to play Entertainer

Program code

More information