Richson Ngu
/
SectionA-1_Richson_19Feb
UPDATED 19FEB
main.cpp
- Committer:
- richson999
- Date:
- 2019-02-19
- Revision:
- 4:9c99c243bc7c
- Parent:
- 3:a1439fe436e9
File content as of revision 4:9c99c243bc7c:
#include "mbed.h" DigitalOut myled(LED1); InterruptIn button1(USER_BUTTON); bool active = false; int indicator = 0; void BUTTON_ISR(){ active = !active; } int main() { // Set up button1.mode(PullUp); button1.fall(&BUTTON_ISR); while(1){ if(active == true){ if (indicator == 0){ myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); BUTTON_ISR(); indicator = 1; } else{ myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); myled = 1; wait(0.2); myled = 0; wait(0.2); BUTTON_ISR(); indicator = 0; } } else{ myled = 0; } __wfi(); //Wait for interruptions } }