Irfan EMG Check

Dependencies:   mbed MODSERIAL

Fork of EMG_check by sibren vuurberg

main.cpp

Committer:
irfanmoh
Date:
2016-09-24
Revision:
4:f83697e01081
Parent:
3:660cdc8db1eb

File content as of revision 4:f83697e01081:

#include "mbed.h"
#include "MODSERIAL.h"

DigitalOut led(LED_RED);
DigitalOut led2(LED_BLUE);
InterruptIn sw3(SW3);
Serial pc(USBTX, USBRX);
int n = 0;

void SwitchN() {
    n++;
    }

int main()
{
  pc.baud(115200);   
  
  while (true) {
    
    sw3.fall(&SwitchN);
    
    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");
         }                 
    }    
           
}
}