Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ESE350-Whack-a-Mole-Slave by
Revision 4:fc72ba6a2048, committed 2015-10-22
- Comitter:
- shibulal
- Date:
- Thu Oct 22 02:16:09 2015 +0000
- Parent:
- 2:77c9b15d79c0
- Commit message:
- final
Changed in this revision
WhackAMole.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/WhackAMole.cpp Wed Oct 21 01:30:55 2015 +0000 +++ b/WhackAMole.cpp Thu Oct 22 02:16:09 2015 +0000 @@ -87,26 +87,44 @@ //Start the timer timer.start(); + bool time_out; + while(true) { //Try to receive some data - + time_out=false; while(true){ rxLen = rf_receive(rxBuffer, 128); if (rxLen>0){ pc.printf("Received: %s\r\n", rxBuffer); //strcpy(rxBuffer,""); - if(!strcmp("activate_1", rxBuffer)) { - break; - } - } - + if(!strcmp("activate_2", rxBuffer)) { + break; + } + else if (!strcmp("check_2", rxBuffer)){ + strcpy(txBuffer, "confirm_2"); + rf_send(txBuffer, strlen(txBuffer)+1); + pc.printf("Sent: %s\r\n", txBuffer); + } + } } led1=1; - while (light_sensor*100>10.0); + while (light_sensor*100>10.0){ + rxLen = rf_receive(rxBuffer, 128); + if (rxLen>0){ + pc.printf("Received: %s\r\n", rxBuffer); + //strcpy(rxBuffer,""); + if(!strcmp("time_out_2", rxBuffer)) { + time_out=true; + break; + } + } + } led1=0; - strcpy(txBuffer, "finished_1"); - rf_send(txBuffer, strlen(txBuffer)+1); - pc.printf("Sent: %s\r\n", txBuffer); + if (!time_out){ + strcpy(txBuffer, "finished_2"); + rf_send(txBuffer, strlen(txBuffer)+1); + pc.printf("Sent: %s\r\n", txBuffer); + } } }