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.
Revision 1:2eeb35548179, committed 2018-11-10
- Comitter:
- mcalzana
- Date:
- Sat Nov 10 15:05:44 2018 +0000
- Parent:
- 0:d9ec23dd131e
- Commit message:
- IOT Assignment 4 Exercise 1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Nov 08 12:18:12 2018 +0000 +++ b/main.cpp Sat Nov 10 15:05:44 2018 +0000 @@ -1,17 +1,24 @@ #include "mbed.h" Ticker toggle_led_ticker; +Serial pc(USBTX, USBRX); DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); + +int counter = 0; void toggle_led() { - led1 = !led1; + int bit1 = counter & 1; + int bit2 = counter & 2; + int bit3 = counter & 4; + led1 = bit1; + led2 = bit2; + led3 = bit3; + counter++; } int main() { - // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms) - toggle_led_ticker.attach(&toggle_led, 0.1); - while (true) { - // Do other things... - } + toggle_led_ticker.attach(&toggle_led, 1); } \ No newline at end of file