This program is a replacement candidate for the original "Blinky LED" demo program which is stored on the STM32F401 Nucleo board, as shipped. Note that the original demo program is, as are all subsequent programs which are flashed to the board, replaced by a later program deposited on the Nucleo which is then loaded by the Nucleo for execution.

Dependencies:   mbed

Committer:
nucleo
Date:
Sun May 18 13:20:12 2014 +0000
Revision:
0:56e6759813dc
STM32F401 Nucleo :: A replacement "Blinky LED" program, similar to the original demo program flashed on the board as shipped. Note that the original demo is erased after a later program is stored and so is not retrievable.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucleo 0:56e6759813dc 1 #include "mbed.h"
nucleo 0:56e6759813dc 2 #include "stdlib.h"
nucleo 0:56e6759813dc 3
nucleo 0:56e6759813dc 4 InterruptIn mybutton(PC_13); // B1
nucleo 0:56e6759813dc 5
nucleo 0:56e6759813dc 6 DigitalOut myled(LED1);
nucleo 0:56e6759813dc 7
nucleo 0:56e6759813dc 8 double multiplier = 500.0; // maximum delay
nucleo 0:56e6759813dc 9
nucleo 0:56e6759813dc 10
nucleo 0:56e6759813dc 11 int delay = 500; // initial on-off time in milliseconds
nucleo 0:56e6759813dc 12
nucleo 0:56e6759813dc 13 void random_on_off() {
nucleo 0:56e6759813dc 14 delay = int(multiplier * float(rand()) / RAND_MAX);
nucleo 0:56e6759813dc 15 }
nucleo 0:56e6759813dc 16
nucleo 0:56e6759813dc 17 int main() {
nucleo 0:56e6759813dc 18 srand(rand());
nucleo 0:56e6759813dc 19 while(1) {
nucleo 0:56e6759813dc 20 myled = !myled;
nucleo 0:56e6759813dc 21 mybutton.fall(&random_on_off);
nucleo 0:56e6759813dc 22 wait_ms(delay);
nucleo 0:56e6759813dc 23 }
nucleo 0:56e6759813dc 24 }