/*############################################################# Program Name : ex7_led_count Author : Grant Phillips Date Modified : 12/01/2016 Compiler : ARMmbed Tested On : STM32F4-Discovery Description : Increments a counter from 0 to 255 repeatedly in 200ms delays and display the count value on 8 LEDs Requirements : * STM32F4-Discovery Board Circuit : * 8 LEDs connected to PD15 - PD8 ##############################################################*/ #include "mbed.h" BusOut myleds(PD_8, PD_9, PD_10, PD_11, PD_12, PD_13, PD_14, PD_15); // bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 . . . int main() { uint8_t count=0; while(1) { myleds = count; //display count on LEDs count = count + 1; //increment count; because count is a 8-bit unsigned value, the count will "roll-over" from 255 back to 0 again wait(0.2); //wait 200ms } }