TVZ Mechatronics Team


Zagreb University of Applied Sciences, Professional Study in Mechatronics

You are viewing an older revision! See the latest version

Introduction

Solve the following tasks with a goal of getting started with mbed NXP LPC1768 platform:

  1. 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.

    Import program

    00001 #include "mbed.h"
    00002 
    00003 DigitalOut myled(LED1);
    00004 
    00005 int main() {
    00006     while(1) {
    00007         myled = 1;
    00008         wait(0.2);
    00009         myled = 0;
    00010         wait(0.2);
    00011     }
    00012 }
    
  2. Examine the documentation for DigitalOut class. Turn any LED on/off using class DigitalOut member function write. Explain the role of operator= in the class documentation.
  3. Modify the Hello World program to flash other 3 LEDs (only one LED can flash).
  4. Modify the program to flash 2 or more LEDs at the same time (almost at the same time).
  5. 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 while and for loops for this task.
  6. Declare and initialize two constant real variables T_TOTAL and 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_TOTAL and 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.
  7. Create a new program that contains one LED and the following blinking pattern:
    1. LED is turned on for 5 seconds, then it is turned off for 0.5 seconds.
    2. After that, the on time decreases to 4 seconds, with fixed off time (0.5 seconds).
    3. The pattern continues until the on time reaches 1 second, and after that the pattern starts from the beginning.
  8. 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).

Congratulations!

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.


All wikipages