Irfan EMG Check

Dependencies:   mbed MODSERIAL

Fork of EMG_check by sibren vuurberg

Files at this revision

API Documentation at this revision

Comitter:
irfanmoh
Date:
Sat Sep 24 09:42:38 2016 +0000
Parent:
3:660cdc8db1eb
Commit message:
Working version. Switch changes UP/DOWN to LEFT/RIGHT

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 660cdc8db1eb -r f83697e01081 MODSERIAL.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Sat Sep 24 09:42:38 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MODSERIAL/#4737f8a5b018
diff -r 660cdc8db1eb -r f83697e01081 main.cpp
--- a/main.cpp	Fri Sep 23 14:41:32 2016 +0000
+++ b/main.cpp	Sat Sep 24 09:42:38 2016 +0000
@@ -1,66 +1,53 @@
 #include "mbed.h"
+#include "MODSERIAL.h"
 
 DigitalOut led(LED_RED);
 DigitalOut led2(LED_BLUE);
-DigitalIn sw2(SW2);
 InterruptIn sw3(SW3);
 Serial pc(USBTX, USBRX);
 int n = 0;
 
-
 void SwitchN() {
     n++;
     }
 
 int main()
 {
-  pc.baud(115200);
-
- // if (sw3 == 0)
- // { // als knopje 3 wordt ingedrukt dan wordt er 1 opgeteld bij n
-   //     n++;
-     //   pc.printf("%i \n\r",n);
-      //  wait (0.5);
-      //  }
-   // else {
-     //   n=n;
-       // pc.printf("geen switch");
-     //    }
-    
+  pc.baud(115200);   
   
   while (true) {
     
     sw3.fall(&SwitchN);
     
-    if (n%2 == 0) { //runt menuutje 1 als het even is
-        //menu 1
-         pc.printf("n is even \n");
-  //       wait (0.5); 
-         
-         char c = pc.getc();
-               if (c == 's'){
-                pc.printf("up \n\r");
-                wait (0.5);
-                }
-                else if (c == 'd'){
-                pc.printf("down \n\r");
-                wait (0.5);}
-            }
-    else {              // runt menuutje 2 als het oneven is
-    // menu 2
-     pc.printf("n is oneven \n\r");
-    //    wait (0.5);
-        char c = pc.getc();
-       if (c == 's'){
-            pc.printf("right \r\n");
-        wait (0.5);}
-       else if (c == 'd'){
-            pc.printf("left \n\r");
-            wait (0.5);}
-        else {}
-       
-       }
-        
+    char c = pc.getc();
+    
+    if (c=='s')
+    {
+         if (n%2==0)
+         {
+           pc.printf("n is even \n\r");
+           pc.printf("up \n\r");           
+         } 
+         else
+         {
+           pc.printf("n is odd \n\r");
+           pc.printf("left \n\r");
+         }            
+    }
+    else if (c=='d')
+    {
+         if (n%2==0)
+         {
+           pc.printf("n is even \n\r");
+           pc.printf("down \n\r");           
+         } 
+         else
+         {
+           pc.printf("n is odd \n\r");
+           pc.printf("right \n\r");
+         }                 
+    }    
+           
 }
 }