István Cserny / Mbed 2 deprecated Lab09_ledblink

Dependencies:   mbed mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 /* RTOS timer example
00003  * This program was borrowed from the book
00004  * 'ARM-Based microcontroller projects using MBED'
00005  * written by Dogan Ibrahim
00006  * Newsnes (an imprint of Elsevier) 2019. ISBN: 978-0-08-102969-5
00007  *
00008  * https://www.sciencedirect.com/book/9780081029695/arm-based-microcontroller-projects-using-mbed
00009  */
00010 
00011 #include "mbed.h"
00012 #include "rtos.h"
00013 DigitalOut led(LED1);
00014 
00015 void Flash() {
00016     led = !led;                  // Flash the LED
00017 }
00018 
00019 int main() {
00020     led = 1;
00021     RtosTimer timer(Flash);      // Create a timer
00022     timer.start(500);            // Start the timer
00023     Thread::wait(5000);          // Wait 5 seconds
00024     timer.stop();                // Stop the timer
00025 
00026     Thread::wait(osWaitForever); // Wait forever
00027 }
00028