UPDATED 19FEB

Dependencies:   mbed

Committer:
richson999
Date:
Tue Feb 19 03:31:18 2019 +0000
Revision:
4:9c99c243bc7c
Parent:
3:a1439fe436e9
UPDATED 19FEB

Who changed what in which revision?

UserRevisionLine numberNew contents of line
selvakumararm 0:bcf6fcde4f32 1 #include "mbed.h"
selvakumararm 0:bcf6fcde4f32 2
selvakumararm 0:bcf6fcde4f32 3 DigitalOut myled(LED1);
selvakumararm 0:bcf6fcde4f32 4 InterruptIn button1(USER_BUTTON);
selvakumararm 0:bcf6fcde4f32 5
selvakumararm 0:bcf6fcde4f32 6 bool active = false;
richson999 4:9c99c243bc7c 7 int indicator = 0;
selvakumararm 0:bcf6fcde4f32 8
selvakumararm 0:bcf6fcde4f32 9 void BUTTON_ISR(){
selvakumararm 0:bcf6fcde4f32 10 active = !active;
selvakumararm 0:bcf6fcde4f32 11 }
selvakumararm 0:bcf6fcde4f32 12
selvakumararm 0:bcf6fcde4f32 13 int main() {
selvakumararm 0:bcf6fcde4f32 14 // Set up
selvakumararm 0:bcf6fcde4f32 15 button1.mode(PullUp);
selvakumararm 0:bcf6fcde4f32 16 button1.fall(&BUTTON_ISR);
selvakumararm 0:bcf6fcde4f32 17
richson999 4:9c99c243bc7c 18 while(1){
richson999 4:9c99c243bc7c 19 if(active == true){
richson999 4:9c99c243bc7c 20 if (indicator == 0){
richson999 4:9c99c243bc7c 21 myled = 1;
richson999 4:9c99c243bc7c 22 wait(0.2);
richson999 4:9c99c243bc7c 23 myled = 0;
richson999 4:9c99c243bc7c 24 wait(0.2);
richson999 4:9c99c243bc7c 25 myled = 1;
richson999 4:9c99c243bc7c 26 wait(0.2);
richson999 4:9c99c243bc7c 27 myled = 0;
richson999 4:9c99c243bc7c 28 wait(0.2);
richson999 4:9c99c243bc7c 29 myled = 1;
richson999 4:9c99c243bc7c 30 wait(0.2);
richson999 4:9c99c243bc7c 31 myled = 0;
richson999 4:9c99c243bc7c 32 wait(0.2);
richson999 4:9c99c243bc7c 33
richson999 4:9c99c243bc7c 34 BUTTON_ISR();
richson999 4:9c99c243bc7c 35 indicator = 1;
richson999 4:9c99c243bc7c 36 }
richson999 4:9c99c243bc7c 37 else{
richson999 4:9c99c243bc7c 38 myled = 1;
richson999 4:9c99c243bc7c 39 wait(0.2);
richson999 4:9c99c243bc7c 40 myled = 0;
richson999 4:9c99c243bc7c 41 wait(0.2);
richson999 4:9c99c243bc7c 42 myled = 1;
richson999 4:9c99c243bc7c 43 wait(0.2);
richson999 4:9c99c243bc7c 44 myled = 0;
richson999 4:9c99c243bc7c 45 wait(0.2);
richson999 4:9c99c243bc7c 46 myled = 1;
richson999 4:9c99c243bc7c 47 wait(0.2);
richson999 4:9c99c243bc7c 48 myled = 0;
richson999 4:9c99c243bc7c 49 wait(0.2);
richson999 4:9c99c243bc7c 50 myled = 1;
richson999 4:9c99c243bc7c 51 wait(0.2);
richson999 4:9c99c243bc7c 52 myled = 0;
richson999 4:9c99c243bc7c 53 wait(0.2);
richson999 4:9c99c243bc7c 54 myled = 1;
richson999 4:9c99c243bc7c 55 wait(0.2);
richson999 4:9c99c243bc7c 56 myled = 0;
richson999 4:9c99c243bc7c 57 wait(0.2);
richson999 4:9c99c243bc7c 58 myled = 1;
richson999 4:9c99c243bc7c 59 wait(0.2);
richson999 4:9c99c243bc7c 60 myled = 0;
richson999 4:9c99c243bc7c 61 wait(0.2);
richson999 4:9c99c243bc7c 62 myled = 1;
richson999 4:9c99c243bc7c 63 wait(0.2);
richson999 4:9c99c243bc7c 64 myled = 0;
richson999 4:9c99c243bc7c 65 wait(0.2);
richson999 4:9c99c243bc7c 66 myled = 1;
richson999 4:9c99c243bc7c 67 wait(0.2);
richson999 4:9c99c243bc7c 68 myled = 0;
richson999 4:9c99c243bc7c 69 wait(0.2);
richson999 4:9c99c243bc7c 70 myled = 1;
richson999 4:9c99c243bc7c 71 wait(0.2);
richson999 4:9c99c243bc7c 72 myled = 0;
richson999 4:9c99c243bc7c 73 wait(0.2);
richson999 4:9c99c243bc7c 74 myled = 1;
richson999 4:9c99c243bc7c 75 wait(0.2);
richson999 4:9c99c243bc7c 76 myled = 0;
richson999 4:9c99c243bc7c 77 wait(0.2);
richson999 4:9c99c243bc7c 78 myled = 1;
richson999 4:9c99c243bc7c 79 wait(0.2);
richson999 4:9c99c243bc7c 80 myled = 0;
richson999 4:9c99c243bc7c 81 wait(0.2);
richson999 4:9c99c243bc7c 82 myled = 1;
richson999 4:9c99c243bc7c 83 wait(0.2);
richson999 4:9c99c243bc7c 84 myled = 0;
richson999 4:9c99c243bc7c 85 wait(0.2);
richson999 4:9c99c243bc7c 86 myled = 1;
richson999 4:9c99c243bc7c 87 wait(0.2);
richson999 4:9c99c243bc7c 88 myled = 0;
richson999 4:9c99c243bc7c 89 wait(0.2);
richson999 4:9c99c243bc7c 90 myled = 1;
richson999 4:9c99c243bc7c 91 wait(0.2);
richson999 4:9c99c243bc7c 92 myled = 0;
richson999 4:9c99c243bc7c 93 wait(0.2);
richson999 4:9c99c243bc7c 94 myled = 1;
richson999 4:9c99c243bc7c 95 wait(0.2);
richson999 4:9c99c243bc7c 96 myled = 0;
richson999 4:9c99c243bc7c 97 wait(0.2);
richson999 4:9c99c243bc7c 98
richson999 4:9c99c243bc7c 99 BUTTON_ISR();
richson999 4:9c99c243bc7c 100 indicator = 0;
richson999 4:9c99c243bc7c 101 }
richson999 4:9c99c243bc7c 102 }
richson999 4:9c99c243bc7c 103 else{
richson999 4:9c99c243bc7c 104 myled = 0;
richson999 4:9c99c243bc7c 105 }
richson999 4:9c99c243bc7c 106
richson999 4:9c99c243bc7c 107 __wfi(); //Wait for interruptions
richson999 4:9c99c243bc7c 108 }
selvakumararm 0:bcf6fcde4f32 109 }
selvakumararm 0:bcf6fcde4f32 110
selvakumararm 0:bcf6fcde4f32 111