Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- nucleo
- Date:
- 2014-05-20
- Revision:
- 0:42458802c36f
- Child:
- 1:61ebf06c61cc
File content as of revision 0:42458802c36f:
#include "mbed.h"
#include "stdlib.h"
#include <Timer.h>
InterruptIn mybutton(PC_13); // B1
DigitalOut myled(LED1);
double multiplier = 500.0; // maximum on-off time in milliseconds
Timer timer;
int delay = 500; // initial on-off time in milliseconds
void random_on_off() {
srand(unsigned(timer.read_ms()% RAND_MAX));
delay = int(multiplier * float(rand()) / RAND_MAX);
}
int main() {
timer.start();
while(1) {
myled = !myled;
mybutton.fall(&random_on_off);
wait_ms(delay);
}
}