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.
main.cpp
- Committer:
- addyi
- Date:
- 2014-11-26
- Revision:
- 0:76669ad2c30b
- Child:
- 1:0072ef0302ec
File content as of revision 0:76669ad2c30b:
#include "mbed.h" DigitalIn b1(p8); DigitalIn b2(p14); DigitalOut led[] = {(LED1), (LED2),(LED3),(LED4)}; bool shortPress =false; bool longPress = false; int counterTime = 0; int counterBlink=4; Ticker timeTasterTest; Ticker timeLedTest; void tasterTest(); void ledTest(); int main() { while(1) { timeTasterTest.attach(&tasterTest,0.01); timeLedTest.attach(&ledTest,0.5); } } void ledTest() { if(shortPress) { if(counterBlink>=0) { led[1]=!led[1]; counterBlink--; } else { led[1]=0; counterBlink=4; } } if(longPress) { led[1]=!led[1]; } } void tasterTest() { if(!b1) { if(counterTime<500) { longPress=false; shortPress=true; counterTime ++; } else { counterTime=0; longPress=true; shortPress=false; } } else { if(longPress) { counterTime=0; longPress=false; shortPress=false; } } }