Test LED, Button Interrupt, Sleepmode, Ticker

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

Go to the documentation of this file.
00001 #include "mbed.h"
00002 
00003 /**
00004  * @file    main.cpp
00005  * @brief   main file.
00006  *
00007  * @addtogroup FirstRun
00008  * @author  Andreas Rehn
00009  * @date    20.02.2014
00010  * @brief   Main module to test led, button und sleepmode together
00011  * @warning functions run with sleep() and with deepsleep() the system must be start up with InterruptIn
00012  * @{
00013  */
00014 
00015 Ticker flipper;
00016 InterruptIn button(USER_BUTTON);
00017 DigitalOut led(LED1);
00018 
00019 /** function to flip the led  */
00020 void flip(void) {
00021     led = !led;
00022 }
00023 
00024 /** main function
00025     * initial param for led \n
00026     * call function flip on rising edge of Button \n
00027     * attach function flip to Ticker with 2 seconds intervall \n
00028     * go to sleep or deepsleep (test the difference) \n
00029     */
00030 int main(void) {
00031     led = 1;
00032     button.rise(&flip);
00033     flipper.attach(&flip, 2.0);
00034     sleep(); 
00035     //deepsleep();
00036     while(1) {
00037     }
00038 }
00039 /** @} */