Snake for Arduino Esplora

This is a sketch for Arduino Esplora with TFT screen.It is a porting of the famous game Snake completely rewritten for this platform. The snake is drown on the screen and its motion is obtained adding another block in front of it and deleting the last one so it seems that the snake is moving. To choose the snake motion direction you have to press the buttons of Arduino Esplora. There is a green beacon on the screen which is the target of the game. You have to eat the beacon with the snake and for each eaten beacon you earn 9 points. You can choose also the speed of the snake through the slider. The code is highly commented so it would be easy to know what it is doing.

Click the button to show the code.

The snake positions are saved into array positions and positions are updated according to the selected speed (by the slider). There are 4 types of motion, one for each direction, and so there are four cases in moveTheSnake function. If a beacon is eaten the last block of the snake is not deleted and snakeLenght is increased, otherwise when the position is updated the last block is deleted printing it black. Also the score is updated printing it black and reprinting the new one in white. All this is done because in such a way the refreshing procedure will be faster than updating all the screen (remember we have a 16 Mhz micro). The beacon is placed on the screen by a random way. The random sequence is initialized with the temperature sensor. If there are more sketch problems feel free to comment.

Happy sketching.


Hi guys,
this blog is about electronic and how it can be used to Make your own DIY project. You will wonder how easy it is. It will be focused on Arduino which is a powerful tool to develop your own applications. I love it and you will love it too. It is an open source and open hardware instrument and there is a lot of documentation on the web, so it will be very easy to obtain what you want with a little searches.
I will try to post some of my projects to guide you on how some things can be realized. So there will be a lot o sketches (written in C) highly commented to explain how the code works and what it is doing with such an operation. If there are misunderstanding feel free to comment for more explanations on what the code is doing, I will try to help you.
Moreover there will be also others programs, not only Arduino ones. As a matter of fact I have fun also developing some applications for Android or PC so also these codes will be posted. Many of them will be done with Processing and I will post also these codes. They are part of the DIY project that I am following and I want to share with you.

Happy sketching.