Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ivanovp
Date:
Fri Mar 07 15:50:57 2014 +0000
Parent:
1:e9d1c42a73ae
Commit message:
User button is handled too.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e9d1c42a73ae -r 4bc0879947ed main.cpp
--- a/main.cpp	Fri Feb 28 06:52:34 2014 +0000
+++ b/main.cpp	Fri Mar 07 15:50:57 2014 +0000
@@ -5,17 +5,33 @@
 // 9600 bauds, 8-bit data, no parity
 //------------------------------------
 
+DigitalOut led(LED1);
+DigitalIn btn(USER_BUTTON);
 Serial pc(SERIAL_TX, SERIAL_RX);
  
-DigitalOut myled(LED1);
- 
-int main() {
+int main() 
+{
   int i = 1;
-  pc.printf("Hello World !\n");
-  while(1) { 
-      wait(1);
-      pc.printf("This program runs since %d seconds.\n", i++);
-      myled = !myled;
+  //pc.baud (115200);
+  pc.printf("Hello World!\r\n");
+  while(1) 
+  {
+      wait (0.95);
+      pc.printf("This program runs since %d seconds.\r\n", i++);
+      led = 1;
+      wait (0.05);
+      led = 0;
+      if (!btn.read()) // Operator '!' shouldn't be needed
+      {
+          // User button pressed
+          pc.printf("User button pressed!\r\n");
+          int j = 20;
+          while (j--)
+          {
+              led = !led;
+              wait (0.05);
+          }
+      }
   }
 }
  
\ No newline at end of file