Modify the BlinkTicker example to use LED1, LED2, and LED3 for showing the three least significant bits of an 8 bit counter
main.cpp
- Committer:
- vicara
- Date:
- 2018-11-13
- Revision:
- 4:188e09ae3df9
- Parent:
- 3:22314e85092e
File content as of revision 4:188e09ae3df9:
#include "mbed.h" Ticker toggle_led_ticker; DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); int8_t counter = 0; void toggle_leds_by_least_significant_bytes() { if(counter & (1 << (0))){ led1 = 1; } else { led1 = 0; } if(counter & (1 << (1))){ led2 = 1; } else { led2 = 0; } if(counter & (1 << (2))){ led3 = 1; } else { led3 = 0; } counter++; } int main() { toggle_led_ticker.attach(&toggle_leds_by_least_significant_bytes, 1); }