rhomb.io
/
digital-write
Deimos IO4 GPIO control example
Diff: main.cpp
- Revision:
- 94:1ab3e0f051e2
- Parent:
- 88:bea4f2daa48c
--- a/main.cpp Fri Mar 22 06:00:05 2019 +0000 +++ b/main.cpp Thu Apr 04 06:57:08 2019 +0000 @@ -1,32 +1,18 @@ -/* mbed Microcontroller Library - * Copyright (c) 2018 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - */ +//Este programa activa y desactiva de forma intermitente el LED y la GPIO4 #include "mbed.h" -#include "stats_report.h" +DigitalOut pin4(IO4); DigitalOut led1(LED1); -#define SLEEP_TIME 500 // (msec) -#define PRINT_AFTER_N_LOOPS 20 - -// main() runs in its own thread in the OS int main() { - SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */); - - int count = 0; - while (true) { - // Blink LED and wait 0.5 seconds - led1 = !led1; - wait_ms(SLEEP_TIME); - - if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) { - // Following the main thread wait, report on the current system status - sys_state.report_state(); - count = 0; - } - ++count; + while(1) { + pin4 = 1; + led1 = 1; + wait(0.2); + pin4 = 0; + led1 = 0; + wait(0.2); } -} +} \ No newline at end of file