This program is a reaction time game for two players on the QW dev kit. The winner and his reaction time are shown in the console window and transmitted via Sigfox.
Fork of QW-Reactiontime by
QW Reaction Time Game
This program is a reaction time game for two players on the QW dev kit. The winner and his reaction time are shown in the console window and transmitted via Sigfox.
Code explanation
The program starts with the initialisation/declaration of the leds and pushbuttons. Also the necessary function prototypes and serial communications are declared. After that, the program is waiting to start the game. While the program is waiting, the leds are looping. Instructions to play the game are displayed in the console window. The game is started by pushing one of the buttons. Then the two players have to wait till all four leds turn on to push their button. The player that pushes the fastest after the leds turn on is the winner. The results of the game are shown in the console window and transmitted via Sigfox.
Sigfox message payload
First there is the "06", this is the Quicksand ID of the example program. This is used by Quicksand to keep track of our example programs. The second value that is transmitted is the ID of the winner. The third and last value that is transmitted is the reaction time of the winner.
More information and other example code can be found on the component page by clicking the link below: https://developer.mbed.org/components/QW-SIGFOX-Development-Kit/
Revision 3:1bc9575369bd, committed 2016-12-15
- Comitter:
- quicksand
- Date:
- Thu Dec 15 13:27:19 2016 +0000
- Parent:
- 2:73b5ca784164
- Commit message:
- changed program ID in Sigfox message
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 15 09:57:11 2016 +0000 +++ b/main.cpp Thu Dec 15 13:27:19 2016 +0000 @@ -114,7 +114,7 @@ LED_3 = 1; winner = 1; char command[SER_BUFFER_SIZE]; - sprintf(command, "AT$SF=05%04x%04x,2,0\n", (int) winner, (int) reactionTime ); + sprintf(command, "AT$SF=06%04x%04x,2,0\n", (int) winner, (int) reactionTime ); pc.printf("Sending winner = %i and reaction time = %i ms over Sigfox\n", winner, reactionTime); pc.printf("using modem command: %s\n", command); modem_command_check_ok(command); @@ -135,7 +135,7 @@ LED_3 = 1; winner = 2; char command[SER_BUFFER_SIZE]; - sprintf(command, "AT$SF=05%04x%04x,2,0\n", (int) winner, (int) reactionTime ); + sprintf(command, "AT$SF=06%04x%04x,2,0\n", (int) winner, (int) reactionTime ); pc.printf("Sending winner = %i and reaction time = %i ms over Sigfox\n", winner, reactionTime); pc.printf("using modem command: %s\n", command); modem_command_check_ok(command);