a

Dependencies:   mbed

Committer:
Dom952
Date:
Sat Apr 23 17:39:54 2016 +0000
Revision:
0:3bd4118e5c71
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Dom952 0:3bd4118e5c71 1 #include "mbed.h"
Dom952 0:3bd4118e5c71 2
Dom952 0:3bd4118e5c71 3 DigitalIn enable(USER_BUTTON);
Dom952 0:3bd4118e5c71 4 DigitalOut led_1(LED1);
Dom952 0:3bd4118e5c71 5 DigitalOut led_2(LED2);
Dom952 0:3bd4118e5c71 6
Dom952 0:3bd4118e5c71 7 int main() {
Dom952 0:3bd4118e5c71 8 while(1) {
Dom952 0:3bd4118e5c71 9 if(enable) {
Dom952 0:3bd4118e5c71 10 led_1 = !led_1;
Dom952 0:3bd4118e5c71 11 }
Dom952 0:3bd4118e5c71 12 else {
Dom952 0:3bd4118e5c71 13 led_2 = !led_2;
Dom952 0:3bd4118e5c71 14 }
Dom952 0:3bd4118e5c71 15 wait(0.1);
Dom952 0:3bd4118e5c71 16 }
Dom952 0:3bd4118e5c71 17 }
Dom952 0:3bd4118e5c71 18
Dom952 0:3bd4118e5c71 19 /*
Dom952 0:3bd4118e5c71 20 DigitalOut led_green(LED1);
Dom952 0:3bd4118e5c71 21 DigitalOut led_red(LED2);
Dom952 0:3bd4118e5c71 22
Dom952 0:3bd4118e5c71 23 InterruptIn user_button(USER_BUTTON);
Dom952 0:3bd4118e5c71 24
Dom952 0:3bd4118e5c71 25 float delay_on = 0.2;
Dom952 0:3bd4118e5c71 26 float delay_off = 1.0;
Dom952 0:3bd4118e5c71 27
Dom952 0:3bd4118e5c71 28 void button_pressed()
Dom952 0:3bd4118e5c71 29 {
Dom952 0:3bd4118e5c71 30 delay_on = 0.1;
Dom952 0:3bd4118e5c71 31 delay_off = 0.1;
Dom952 0:3bd4118e5c71 32 }
Dom952 0:3bd4118e5c71 33
Dom952 0:3bd4118e5c71 34 void button_released()
Dom952 0:3bd4118e5c71 35 {
Dom952 0:3bd4118e5c71 36 delay_on = 0.2;
Dom952 0:3bd4118e5c71 37 delay_off = 1.0;
Dom952 0:3bd4118e5c71 38 }
Dom952 0:3bd4118e5c71 39
Dom952 0:3bd4118e5c71 40 int main()
Dom952 0:3bd4118e5c71 41 {
Dom952 0:3bd4118e5c71 42 user_button.rise(&button_pressed);
Dom952 0:3bd4118e5c71 43 user_button.fall(&button_released);
Dom952 0:3bd4118e5c71 44
Dom952 0:3bd4118e5c71 45 while(1) {
Dom952 0:3bd4118e5c71 46 // LEDs are ON
Dom952 0:3bd4118e5c71 47 led_green = 1;
Dom952 0:3bd4118e5c71 48 led_red = 1;
Dom952 0:3bd4118e5c71 49 wait(delay_on);
Dom952 0:3bd4118e5c71 50 // LEDs are OFF
Dom952 0:3bd4118e5c71 51 led_green = 0;
Dom952 0:3bd4118e5c71 52 led_red = 0;
Dom952 0:3bd4118e5c71 53 wait(delay_off);
Dom952 0:3bd4118e5c71 54 }
Dom952 0:3bd4118e5c71 55 }*/