George Cochrane / Mbed 2 deprecated ScoreCount2

Fork of ScoreCount by George Cochrane

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers reciever.cpp Source File

reciever.cpp

00001              #include "mbed.h"
00002 
00003 char string[64];
00004 int p;
00005 
00006 
00007 int Interrogate()
00008 {
00009 Serial pc(USBTX,USBRX);
00010 Serial myserial(PTC4,PTC3);
00011 myserial.baud(1200);
00012 DigitalOut blueled(LED1);
00013 
00014     while(1) 
00015          {
00016            while(!myserial.readable())
00017                 {
00018                   blueled=1;
00019                 }
00020            
00021            if(myserial.readable())
00022              {
00023              blueled=0;
00024             myserial.scanf("%s",string);
00025               pc.printf("\n\r%s", string);    
00026              if((strstr (string,"011")) != NULL)
00027                {
00028                  p = 1;
00029                }
00030              if((strstr (string,"012")) != NULL)
00031                {
00032                  p = 2;
00033                }
00034              if((strstr (string,"013")) != NULL)
00035                {
00036                  p = 3;
00037                }
00038              if((strstr (string,"014")) != NULL)
00039                {
00040                  p = 4;
00041                }
00042              for(int f=0;f<5;f++)
00043              {
00044              blueled=!blueled;
00045              wait(0.2);  
00046                pc.printf("\n\r%d", p);         
00047              return p;  
00048              }                       
00049              }           
00050          }
00051 }