The example program for mbed pin-compatible platforms

Dependencies:   mbed

Fork of mbed_blinky by Mbed

Revision:
7:97872775e085
Parent:
4:81cea7a352b0
--- a/main.cpp	Fri May 09 19:58:03 2014 +0300
+++ b/main.cpp	Mon Oct 06 16:54:04 2014 +0000
@@ -1,12 +1,23 @@
 #include "mbed.h"
 
-DigitalOut myled(LED1);
-
+DigitalIn diginput(p7);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+ /*
+ Wire a mechanical button so that it connects the pin 'p7' and GND.
+ Then pressing the mechanical button causes 'diginput' ==  0.
+ The LED 'led1' lights while the mechanical button is not pressed.
+ The LED 'led2' blinks while the mechanical button is pressed.
+ */
 int main() {
     while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+        if(diginput) { // the mechanical button is not pressed.
+            led1 = 1;
+            led2 = 0;            
+        } else {       // the mechanical button is pressed.
+            led1 = 0;
+            led2 = !led2;
+        };
+        wait(0.25);
     }
 }