Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: CSC1300_EduBaseV2_Lab0 mbed_blinky EduBaseV2_Lab0 mbed_blinky ... more
Tutorial 4 New Program and Import
Creating a New Program and Importing a Library¶
For each lab, you will have to create a new program with a main.cpp, the mbed software development kit (SDK), and the custom-built TTU_CSC1300 library. This tutorial will show you how to create a new program to complete your lab assignment on the EduBase-V2.
How to Create a New Program¶
In this section, you will learn how to create a new program and how to prepare your main.cpp with the template code that we have provided.
1. Go to the Mbed IDE home page at https://ide.mbed.com.
2. Click on the New button in the top left corner. If a selection box appears below the New button, click on the option that says "New Program."
3. Make sure the text box that appears on your screen says, "Create new program." If it does, type in "CSC1300_EduBaseV2_Lab#" as the Program Name with # being the current EduBase lab number (e.g. CSC1300_EduBaseV2_Lab0). Keep the settings for Platform and Template. Check the box that says, "Update this program and libraries to latest revision," if not already checked.
4. Once you create a new program, you should be taken to a page that looks like the one below with the program's contents. You should see two items: the main.cpp source file and the mbed SDK. The mbed SDK is the official software development kit (SDK) that allows you to create and compile your software applications on the Mbed platform. You will not be able to compile your program at all without the mbed SDK, so don't delete it!
5. Click on the file called main.cpp. This source file is where you will write the main contents of your program inside the main function, hence the name main.cpp. Your main.cpp should look like this.
6. Uh-oh! What's all this? Don't worry, you will not be using any of this code in any of your future labs. What you will need to do is copy and paste the template code provided in the Template Code page to replace all of the current contents of your main.cpp. After you copy and paste the template code, your main.cpp should look like the picture below.
Now, that doesn't look as intimidating, doesn't it?
How to Import a Library/Program¶
You are now halfway done in preparing your program for your lab! For each of your EduBase labs this semester, you will have to import a library called TTU_CSC1300 that will contain two files: TTU_CSC1300.cpp and TTU_CSC1300.h. You will not be making any edits to these two files. The TTU_CSC1300 library was custom built so that you could program the EduBase-V2 using the Nucleo F031K6. These files contain a lot of the "behind the scenes" code that will allow you to run your program in main.cpp. You will not be able to properly compile your program without this library, so make sure you have imported it before each lab.
Here are the steps on how to import the TTU_CSC1300 library into your new program:
1. Click on the name of the program you want to import your library into (which should be the current lab you are working on) to highlight it. Then, press the Import button in the top left corner. Once you are on the Import Wizard page, select the Libraries tab.
2. Type in TTU_CSC1300 in the search bar. Once the TTU_CSC1300 library appears in the search results, click on its line once to highlight it in orange. Then, press the box above the search bar that says "Import!"
3. Make sure the text box that appears on your screen says, "Import Library." Check that the Import As setting has the Library option selected. Make sure that the Target Path is the program that you want to import the library into (the current lab you are working on). Press Import.
4. You will be then directed to a screen that looks like this. If you look in your Program Workspace, you will see that the TTU_CSC1300 library has been added to your current program, which in our example is CSC1300_EduBaseV2_Lab0.
You can now create your own program and import a library on Mbed. In the next tutorial, you will learn about Saving, Committing, and Publishing a Program in Mbed, which will introduce you to version control and show you how to publish your program so that you can submit your solution for grading.