Introduction: Snake Game With Scores in LabVIEW
The idea for this project was to modify the existing snake game code so that the score is read in LabVIEW using a serial print command to send the score over a USB cable from the uC32 to the computer running LabVIEW. LabVIEW then takes this score and displays it as well as the top 3 high scores. If the score is one of the high scores, it replaces the lowest score and the array is refreshed to show the high scores from high to low.
Check out this Instructable to see how the 900 LED panel was built and for a small code walkthrough. The updated snake game code that prints each score is linked below.
Step 1: Required Software
Step 2: LabVIEW Code
Pictured above are the front panel and block diagram for the snake game high score. When a game is finished, the score is sent over the USB cable connected to a uC32 and read in LabVIEW using the VISA read function. The case structure makes sure that there are bytes available on the serial connection before reading. The code uses a serial write which just sends the actual decimal value across the serial line in one byte. During the game, serial writes contain a "1" and then the length of the snake. For case "1", the score is updated continuously. After the game is over, a "2" and then the final length of the snake is sent. For case "2", the final score is shown and if it is a high score, the user will be prompted to enter their name and the high scores will be updated.
Download the code below and just choose the COM port that the uC32 is connected to. Refer to this Instructable if you aren't sure which COM port corresponds to the uC32. When that is done, click the run button and the scores will be displayed on the front panel.
If you have any questions, feel free to leave a comment!