Snake Game with Score Tracking in LabVIEW

In preparation for NI week, we decided to resurrect our snake game with a new twist.  Score tracking and high scores in LabVIEW!  While the snake is alive, the score is updated continuously.  Once your snake dies, your final score will be shown on the front panel of LabVIEW and if you have a high score, you will be asked to input your name and the high scores will be updated.  You can find the Instructable for this project here.  Below is a picture of the front panel for LabVIEW.



If you haven’t already, check out our video of the 900 LED board below!

For this project, I used LabVIEW, MPIDE, Marshall’s PIXcel library, a chipKIT uC32, and NI VISA (an add-on for LabVIEW that let’s you read from a serial line).  During the run, a serial.write command in MPIDE is used to send a “1” and then another serial.write follows that contains the length of the snake.  LabVIEW then reads these values and updates the current snake score.  When the snake game ends, a serial.write command sends a “2” followed by the final snake score.  LabVIEW reads the “2” in front of the length and determines whether or not this is a high score.  If it is a high score, the user is asked to input their name and the high scores are updated.  All of the high scores are saved to the computer so that when the LabVIEW code is shut off or the snake game is disconnected and then reconnected the overall high scores are shown.  Here is a picture of the LabVIEW code I wrote.



Check out the code linked in the instructable and see if you can use it as a guide to write your own LabVIEW code to read serial data from a board!  Let me know if you have any questions and I will be happy to answer them.


Leave a Reply

Your email address will not be published. Required fields are marked *