init
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "test_env.h" 00003 00004 RawSerial pc(USBTX, USBRX); 00005 00006 Ticker flipper_1; 00007 DigitalOut led1(LED1); 00008 00009 void flip_1() { 00010 static int led1_state = 0; 00011 if (led1_state) { 00012 led1 = 0; led1_state = 0; 00013 } else { 00014 led1 = 1; led1_state = 1; 00015 } 00016 pc.putc('*'); 00017 } 00018 00019 Ticker flipper_2; 00020 DigitalOut led2(LED2); 00021 00022 void flip_2() { 00023 static int led2_state = 0; 00024 if (led2_state) { 00025 led2 = 0; led2_state = 0; 00026 } else { 00027 led2 = 1; led2_state = 1; 00028 } 00029 } 00030 00031 int main() { 00032 MBED_HOSTTEST_TIMEOUT(15); 00033 MBED_HOSTTEST_SELECT(wait_us_auto); 00034 MBED_HOSTTEST_DESCRIPTION(Ticker Int); 00035 MBED_HOSTTEST_START("MBED_11"); 00036 00037 led1 = 0; 00038 led2 = 0; 00039 flipper_1.attach(&flip_1, 1.0); // the address of the function to be attached (flip) and the interval (1 second) 00040 flipper_2.attach(&flip_2, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds) 00041 00042 while (true) { 00043 wait(1.0); 00044 } 00045 }
Generated on Tue Jul 12 2022 13:24:55 by
1.7.2