iDNA Studio
/
nRF52840-Preview-DK-blinky
pull
Fork of nRF52840-Preview-DK-blinky by
Revision 2:26e1d1bf3d08, committed 2017-02-07
- Comitter:
- idna
- Date:
- Tue Feb 07 08:21:24 2017 +0000
- Parent:
- 1:a0c2e5593bf8
- Commit message:
- Testing blinky;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r a0c2e5593bf8 -r 26e1d1bf3d08 main.cpp --- a/main.cpp Mon Feb 06 13:27:24 2017 +0000 +++ b/main.cpp Tue Feb 07 08:21:24 2017 +0000 @@ -1,79 +1,73 @@ #include "mbed.h" //DigitalOut led1(LED1); -DigitalOut led1(P0_13); +DigitalOut led1(P0_13);// nRF52840 io DigitalOut led2(P0_14); DigitalOut led3(P0_15); DigitalOut led4(P0_16); - -InterruptIn button1(P0_11);//(USER_BUTTON); +InterruptIn button1(P0_11);//(USER_BUTTON nRf52840); InterruptIn button2(P0_12); InterruptIn button3(P0_24); InterruptIn button4(P0_25); +int button3_flag=0; void button1_pressed() { - led1 = led2 =led3 =led4 = 1; - led1 = 0; - + led1 = 0; } void button1_released() { - led1 = led2 =led3 =led4 = 1; - //led1 = 0; + led1 = led2 =led3 =led4 = 1;// LED OFF + //led1 = 0; } void button2_pressed() { - led1 = led2 =led3 =led4 = 1; - led2 = 0; - + led2 = 0; + } void button2_released() { - led1 = led2 =led3 =led4 = 1; - //led1 = 0; + led1 = led2 =led3 =led4 = 1; + //led1 = 0; } void button3_pressed() { - led1 = led2 =led3 =led4 = 1; - led3 = 0; - // wait(0.1); + button3_flag = 1; + } void button3_released() { - led1 = led2 =led3 =led4 = 1; - //led1 = 0; + led1 = led2 =led3 =led4 = 1; + //led1 = 0; + button3_flag=0; } void button4_pressed() { - led1 = led2 =led3 =led4 = 1; - led4 = 0; - + led4 = 0; + } void button4_released() { - led1 = led2 =led3 =led4 = 1; - //led1 = 0; + led1 = led2 =led3 =led4 = 1; + //led1 = 0; } -// main() runs in its own thread in the OS -// (note the calls to Thread::wait below for delays) +int main() +{ + led1 = led2 =led3 =led4 = 0; -int main() { - led1 = led2 =led3 =led4 = 0; - button1.fall(&button1_pressed); button1.rise(&button1_released); - + button2.fall(&button2_pressed); button2.rise(&button2_released); @@ -83,16 +77,25 @@ button4.fall(&button4_pressed); button4.rise(&button4_released); - + while (true) { - // led1 = !led1; - // wait(0.5); - // led2 = !led2; - // wait(0.5); - // led3 = !led3; - // wait(0.5); - // led4 = !led4; - // wait(0.5); + if(button3_flag == 1) { + led3 = 0; + wait(0.1); + led3 = 1; + wait(0.1); + } else { + + + led1 = !led1; + wait(0.5); + led2 = !led2; + wait(0.5); + led3 = !led3; + wait(0.5); + led4 = !led4; + wait(0.5); + } } }