Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 #ifdef TARGET_NUCLEO_F103RB 00004 #define MY_LED PC_13 00005 #define MY_BUTTON NC 00006 #else 00007 #define MY_LED LED1 00008 #define MY_BUTTON USER_BUTTON 00009 #endif 00010 00011 DigitalOut myled(MY_LED); 00012 00013 00014 volatile int updatedLED = 0; 00015 00016 00017 void ButtonPressed(void) { 00018 myled = !myled; 00019 updatedLED++; 00020 } 00021 00022 int main() 00023 { 00024 Serial ser(USBTX, USBRX); 00025 ser.baud(230400); 00026 00027 InterruptIn *event = NULL; 00028 if (MY_BUTTON != NC) { 00029 event = new InterruptIn(MY_BUTTON); 00030 event->fall(&ButtonPressed); 00031 // event.mode(PullUp); 00032 } 00033 00034 int intrnos = 0; 00035 00036 ser.printf("Hello, World\r\n"); 00037 ser.printf("SysClock: %u Hz.\r\n", SystemCoreClock); 00038 00039 int i = 0; 00040 00041 for(;;) { 00042 while(i < 5) { 00043 myled = 1; // LED is ON 00044 wait(0.2); // 200 ms 00045 myled = 0; // LED is OFF 00046 wait(1.0); // 1 sec 00047 i++; 00048 } 00049 sleep(); 00050 ser.printf("Wakeup: %d Intr: %d\r\n", ++intrnos, updatedLED); 00051 myled = !myled; 00052 wait(0.1); 00053 } 00054 }
Generated on Wed Jul 13 2022 22:45:46 by
1.7.2