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.
Fork of mbed-os-example-mbed5-blinky by
main.cpp
00001 #include "mbed.h" 00002 00003 DigitalOut led1(LED1); 00004 00005 Serial pc(USBTX, USBRX); 00006 00007 // blink a number in binary // 00008 void blink_in_binary (int number); 00009 00010 // main() runs in its own thread in the OS 00011 int main() { 00012 // pc.baud(9600); 00013 int number; 00014 number = 0; 00015 while (true) { 00016 while (!pc.readable()); 00017 pc.scanf("%d", &number); 00018 pc.printf("you entered %d\n", number); 00019 blink_in_binary(number); 00020 } 00021 } 00022 00023 // recursivelly prints left-to-right // 00024 void blink_in_binary (int number) 00025 { 00026 if (number <= 0) 00027 return; 00028 blink_in_binary (number >> 1); 00029 led1 = number & 1; 00030 wait(0.3); 00031 led1 = 0; 00032 wait(0.3); 00033 }
Generated on Tue Jul 19 2022 15:47:59 by
1.7.2
