writing values on a led
Dependencies: Hotboards_leds mbed
main.cpp
00001 00002 /* 00003 * This program blinks a led but this time we will show you 00004 * how to use the write function to manipulate the led state 00005 * according to a variable value 00006 * 00007 */ 00008 00009 #include "mbed.h" 00010 #include "Hotboards_leds.h" 00011 00012 //bitRead macro taken from arduino 00013 #define bitRead( var, bit ) (((var) >> (bit)) & 0x01) 00014 00015 Hotboards_leds led( PA_5 ); 00016 00017 uint8_t counter; 00018 00019 int main() 00020 { 00021 while(1) 00022 { 00023 //The led will blink because we are writing the LSB 00024 //of the variable counter which on each iteration 00025 //is incremented by 1. 00026 led.write( bitRead( counter , 0 ) ); 00027 wait_ms( 200 ); 00028 counter ++; 00029 } 00030 }
Generated on Fri Jul 15 2022 05:07:37 by
1.7.2
Roman Valencia