LED and button system

Dependencies:   mbed

Fork of LED by CHANG rozen

Committer:
e58136782000
Date:
Fri Oct 20 07:29:03 2017 +0000
Revision:
2:7bb4b5066464
Parent:
1:59cafc988b1c
Child:
3:684d085cd132
LED and button

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rozendhyan 0:6e75cf3220cb 1 #include "mbed.h"
rozendhyan 0:6e75cf3220cb 2
rozendhyan 0:6e75cf3220cb 3 DigitalOut led1(D4);
rozendhyan 0:6e75cf3220cb 4 DigitalOut led2(D5);
rozendhyan 0:6e75cf3220cb 5 DigitalOut led3(D6);
e58136782000 1:59cafc988b1c 6 DigitalIn button(D7);
rozendhyan 0:6e75cf3220cb 7 void LED_Blinkly(DigitalOut led1,DigitalOut led2,DigitalOut led3);
rozendhyan 0:6e75cf3220cb 8 // main() runs in its own thread in the OS
e58136782000 1:59cafc988b1c 9 int main()
e58136782000 1:59cafc988b1c 10 {
e58136782000 1:59cafc988b1c 11 while(1)
e58136782000 1:59cafc988b1c 12 {
e58136782000 1:59cafc988b1c 13
e58136782000 2:7bb4b5066464 14 if(button == false)
e58136782000 1:59cafc988b1c 15 {
e58136782000 1:59cafc988b1c 16 led1 =! led1;
e58136782000 1:59cafc988b1c 17 wait(0.5);
e58136782000 1:59cafc988b1c 18 led2 =! led2;
e58136782000 1:59cafc988b1c 19 wait(0.5);
e58136782000 1:59cafc988b1c 20 led3 =! led3;
e58136782000 1:59cafc988b1c 21 wait(0.5);
e58136782000 1:59cafc988b1c 22 }
e58136782000 1:59cafc988b1c 23 else
e58136782000 1:59cafc988b1c 24 {
e58136782000 1:59cafc988b1c 25 led1 = false;
e58136782000 1:59cafc988b1c 26 led2 = false;
e58136782000 1:59cafc988b1c 27 led3 = false;
e58136782000 1:59cafc988b1c 28 }
e58136782000 1:59cafc988b1c 29 }
e58136782000 1:59cafc988b1c 30 }