Modify the BlinkTicker example to use LED1, LED2, and LED3 for showing the three least significant bits of an 8 bit counter
Diff: main.cpp
- Revision:
- 3:22314e85092e
- Parent:
- 2:d6c1c30a35a7
- Child:
- 4:188e09ae3df9
--- a/main.cpp Tue Nov 13 13:40:38 2018 +0000 +++ b/main.cpp Tue Nov 13 13:52:53 2018 +0000 @@ -9,23 +9,26 @@ int8_t counter = 0; void toggle_leds_by_least_significant_bytes() { - if(counter&1){ + + if(counter & (1 << (0))){ led1 = 1; } else { led1 = 0; } - if(counter&2){ + if(counter & (1 << (1))){ led2 = 1; } else { led2 = 0; } - if(counter&3){ + if(counter & (1 << (2))){ led3 = 1; } else { led3 = 0; } + + printf("%u - %u - %u \n", counter & (1 << (0)), counter & (1 << (1)), counter & (1 << (2))); counter++; }