It is actually a game designed on 1976. Too young for that? check this link then: https://en.wikipedia.org/wiki/Snake_(video_game_genre)
Well, a special member of our community decided to give it a double twist and make it playable in a cube! At the moment of writing this post, Tokysnake Game 3D is the most astonishing projects the community has done with the Tokymaker.
Get ready for a very complete project, including electronics, 3D design, 3D printing, connections, abstraction, internet of things and coding, a lot of coding.
Of course, this can be easily done if you just download the templates, the 3D model, and the code we post here.
Please sit down and enjoy the ride.
Materials & Tools
There will be a lot of connections. Thus, we will use Male to Female cables.
We will use a big servo motor, capable of moving the LED Cube. It has to be continuous rotation servo.
This is one of our preferred fast prototyping materials. It is a hard plastic that melts in water at 60ºC, so you can re-shape it however you want. Pretty much like play-dough. It is perfect to do organic structures rapidly. After it cools down, it is plastic-hard again.
The snake will move right or left, so at least we need two push buttons. this one contains 5 buttons, but only 2 will be used.
The cube will be rotating, and you need a joystick to controll where to rotate it. With this and the buttons, you will make a game controller.
Yes, this time we will 3D print a structure to keep all the LED matrix together.
This is a two-dimensional matrix of Neopixel LED. The Cube requires 6 matrix like this one.
In this section, we will explain some important aspects of the elaboration of this amazing game. This is important if you want to deeply understand how it works and the complexity underneath it.
However, if you are just looking for a fun project to replicate, can go directly to the next section where we cover a step by step to follow.
The trigonometricic part of the design part is the hardest. To visualize where the snake should go when changing side of the cube is not trivial. You have to take into account that the LED 8x8 Matrix is just an array of 64 LED placed in square shape. It means that there is not rows or collums, but only one dimension. For this reason, it is hard to visualize to what position of the array the snake should move in every circumstance.
To alleviate this situation, Ben made a nice 3D design of the cube positions. Thanks to that, It is easier to visualize it, hence to code it.
In order to make the cube of LEDs You can print this 3D model. Alternatively, if you do not have much time to wait, try to do it with the polimorph plastic.
Download the 3D visualization for sketch up here:TokySnake_CubeVisualisation.zip (15 downloads)
Connecting all the 6 sides together neatly can be a challenge. Therefore Ben provided a nice and simple 3D model that helps out with the building process of it. You can ask to the nearest Hackerspace or Fablab to have it printed for you. Do not worry for the cables not being nicely placed inside the cube, nobody will see them 😉
Just make sure that the LED matrix have the cables connected and that you put a number to every side of the cube.
Download the 3D model here:TokySnake_3D_print_cube.zip (20 downloads)
Alternatively, if you do not have much time to wait, try to do it with the polymorph plastic.
The cube rotating was another challenge to surpass during the elaboration of the TokySnake.
If we want to see all the sides, we obviously need some sort of rotating system for the cube while keeping the game controller steady. The problem remains on the fact that there are cables inside the cube that will twist and brake if it is rotating continuously. The first idea was to embedd the tokymaker inside the cube, but then there was a problem with the cables that goes to the game controller.
Therefore, Ben dedided to use the Sliprin:
TIP: be careful when assembling, this accesory is fragile.
Furthermore, the cube has to be as steady as possible. One possibility was to have it hanged upside down, but the final configuration is the one you see in the picture.
The code overall has around 3000 blocks. Obviously, the processor requires time to process all the instructions in every loop.
Also, there are functions that slow the Tokymaker down. For example the screen display, or to change the colour of the LED lights.
In the same time, we want a smooth movement of the snake over the LED Cube. Not having LEDs flickering due to the processing delay.
Therefore, we need to optimize the code.
Electronic connection Instructions
- Download the 3D model from the link provided above.
- Attach the LED Matrix according to the 3D visualization sketch up provided above. The sides with the same colour mean that it’s matrix panels are connected in series.
- Pass all the cables of the cube trough the Slipring. (the purchase link is provided in the material list)
- Connect all the Inputs and Outputs into the Tokymaker ( You can see in the code where every cable is connected)
- Button A to IN1
- Button B to IN2
- Joystick to IN3
- Motor to OUT 4 or 5
- LED Matrix are connected from OUT1 to OUT3
Body Assembly Instructions
Now let’s connect the Tokymaker to Bluetooth and work on the code!
Game Controller building
The game controller is made with polymorph plastic. Basically we pour a gentle quantity of plastic pellets onto 60ºC water. After 30 seconds we can start making the shape of our will.
TIP: be careful, as the hot polymorph plastic is easily attached to other cables such as plastic cables. We strongly recomend you doing some tests first to familiarize with the material.
Getting Started with IOT
we’re using IOT in this project to send the high score to a public ranking. This way we can see how much is being used and who is the winner!
Once both accounts are created, we will move onto setting up the applet:
If you don’t understand these steps or it is the first time you do an IoT project, please go to www.tokylabs.com/learn and follow the instructions of the project called “International Space Station Notifier” ( link: http://tokylabs.com/wp-content/uploads/2018/08/ISS_notifier_tokymaker_iot.pdf )
Step 1: Create a feed on Adafruit.
Make sure you’re on io.adafruit.com in order to create a feed.
Under Actions, select Create a New group called snake.
Inside the group, create the Feed called hs
This way, in the code the name of the feed is snake.hs
Once the IoT part is configured, and the TokySnake is well assembled, we can go for the coding part.
Download the fully operational code here:
Go To Shop
Find different sensors and accessories in the shop to help make your project a success!
Description of Benjamin