Zagreb University of Applied Sciences, Professional Study in Mechatronics
Each of your programs should contain only one file named main.cpp. Inside your program folder don't add new files with .cpp extension. To create a new program in Mbed compiler you need select
New (top left corner of menu bar) and then in the drop down menu select
New program .
Solve the following tasks with a goal of getting started with mbed NXP LPC1768 platform:
- Read the introduction to the mbed LPC1768 microcontroller. Check if the latest board firmware is installed. If not, update the firmware to the latest revision using these instructions. Start the Hello World program.
- Examine the documentation for
DigitalOutclass. Turn any LED on/off using class
write. Explain the role of
operator=in the class documentation. There is two ways to view documentation:
- Mbed Compiler, on the left side is placed directory tree, inside that tree you need to open folder with your program in it, that you named e.g. Introduction. This folder contains file main.cpp and mbed library (cog icon). There are three sub-libraries in the mbed library, you need to open the document named Classes and find the class whose documentation you want to study.
- on the following links you can find documentation for all the classes we will use in this course (and at CTM): old documentation that is still valid and contains examples and new documentation that also contains examples but also a more comprehensive description of the classes.
- Modify the Hello World program to flash other 3 LEDs (only one LED can flash).
- Modify the program to flash 2 or more LEDs at the same time (almost at the same time).
- Create a new program. Inside the newly created program, modify the program from previous task to flash the LED1 for 4 seconds, then turn off LED1 and flash LED2 for 4 seconds, turn off LED2 and go back to flash LED1 for 4 seconds etc. Use the
forloops for this task.
- Declare and initialize two constant real variables
T_FLASH, which will determine the total flash time of individual LEDs from the previous task, as well as the duration of each flash. E.g. instead of 4 seconds, set the total of 10 seconds for
T_TOTALand instead of default 0.2 seconds for
T_FLASH, set the 0.5 seconds. The idea is to make a change only on those two places, and the rest of the code must carry out the task.
- Create a new program that contains one LED and the following blinking pattern:
- LED is turned on for 5 seconds, then it is turned off for 0.5 seconds.
- After that, the on time decreases to 4 seconds, with fixed off time (0.5 seconds).
- The pattern continues until the on time reaches 1 second, and after that the pattern starts from the beginning.
- Generalize the previous program to include the on time in a variable that can be set to an arbitrary integer value. The on time decrement remains the same (1 second).
You have completed all the exercises in the Introduction topic. More interesting exercises are coming in the following topics!
Return to TVZ Mechatronics Team Homepage.