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 int counter = 0; 00010 00011 void toggle_led() { 00012 // We give the bits value of 1 and shifting the bits to the left based on the right number. 00013 (counter & (1 << (0))) ? led1 =1 : led1 = 0; 00014 00015 (counter & (1 << (1))) ? led2 = 1 : led2 = 0; 00016 00017 counter & (1 << (2)) ? led3 = 1 : led3 = 0; 00018 00019 } 00020 00021 int main() { 00022 // Init the ticker with the address of the function (toggle_led) to be attached and the interval (2000 ms) 00023 toggle_led_ticker.attach(&toggle_led, 2); 00024 while (true) { 00025 // increment the counter 00026 wait(2); 00027 counter ++; 00028 } 00029 }
Generated on Sat Jul 30 2022 08:20:39 by
1.7.2