Peter's version

Fork of ScoreCount by George Cochrane

reciever.cpp

Committer:
gcme93
Date:
2013-05-03
Revision:
6:e269f6c282bc
Parent:
5:a50e02fc49cd

File content as of revision 6:e269f6c282bc:

             #include "mbed.h"

char string[64];
int p;


int Interrogate()
{
Serial pc(USBTX,USBRX);
Serial myserial(PTC4,PTC3);
myserial.baud(1200);
DigitalOut blueled(LED1);

    while(1) 
         {
           while(!myserial.readable())
                {
                  blueled=1;
                }
           
           if(myserial.readable())
             {
             blueled=0;
            myserial.scanf("%s",string);
              pc.printf("\n\r%s", string);    
             if((strstr (string,"011")) != NULL)
               {
                 p = 1;
               }
             if((strstr (string,"012")) != NULL)
               {
                 p = 2;
               }
             if((strstr (string,"013")) != NULL)
               {
                 p = 3;
               }
             if((strstr (string,"014")) != NULL)
               {
                 p = 4;
               }
             for(int f=0;f<5;f++)
             {
             blueled=!blueled;
             wait(0.2);  
               pc.printf("\n\r%d", p);         
             return p;  
             }                       
             }           
         }
}