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
Fork of FTF2014_lab2_complete by
main.cpp
- Committer:
- Kojto
- Date:
- 2014-04-03
- Revision:
- 0:3561cbaefc3d
File content as of revision 0:3561cbaefc3d:
#include "mbed.h"
DigitalOut led_red(LED_RED);
InterruptIn sw2(SW2);
Ticker ticker;
float interval;
void led_toggle(void)
{
led_red = !led_red;
}
void sw2_release(void)
{
printf("On-board button SW2 was released.\n");
}
void sw2_press(void)
{
printf("On-board button SW2 was pressed.\n");
interval -= 0.1f;
ticker.detach();
ticker.attach(&led_toggle, interval);
printf("LED toogle interval was set to: %f \n", interval);
if (interval < 0.5f) {
interval = 1.1f;
}
}
int main()
{
interval = 1.0f;
sw2.rise(&sw2_release);
sw2.fall(&sw2_press);
ticker.attach(&led_toggle, interval);
while (true) {
}
}
