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 Ticker toggle_led_ticker; 00004 00005 DigitalOut led1(LED1); 00006 DigitalOut led2(LED2); 00007 DigitalOut led3(LED3); 00008 00009 static int value = 0; 00010 00011 #define LEAST_1 1 00012 #define LEAST_2 1 << 1 00013 #define LEAST_3 1 << 2 00014 00015 void toggle_leds() { 00016 led1 = value & LEAST_1; 00017 led2 = value & LEAST_2; 00018 led3 = value & LEAST_3; 00019 } 00020 00021 int main() { 00022 // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms) 00023 00024 toggle_led_ticker.attach(&toggle_leds, 0.1); 00025 while (true) { 00026 value++; 00027 if (value == 256) { 00028 value = 0; 00029 } 00030 wait(1); 00031 } 00032 }
Generated on Mon Jul 25 2022 02:48:03 by
1.7.2