Close
0%
0%

ATtiny85 1D Game Console

A game console using the best of all microcontroller: the ATtiny85

Similar projects worth following
114 views
0 followers
Like the title says: a game console built around the ATtiny85, using 3 buttons as input and 8 (or more) WS2812 LEDs as display.

As my first idea for a game was pong, this is the most thought out game yet.

The Idea and the PCBWay sponsorship

My goal for this project was straightforward: to create a compact and functional gaming console using an ATtiny85 and WS2812 LEDs. The challenge was to maximize functionality within the constraints of the ATtiny85's limited pins, RAM, and Flash memory. To conserve memory, I opted for hardware-based debouncing using capacitors, eliminating the need for software debouncing routines, which would have consumed valuable memory.

I got the PCBs and the printed enclosure sponsored by PCBWay. While the PCBs with the purple finish are definitely a treat to my eyes, I think the real deal is the printed transparent case.  The Layer lines are only visible under a certain angle and there are no visible leftovers from support structure. I mean just look at it, it's so beautiful... and certainly better than everything I could have printed at home. Also ordering it was straight forward, even though I was not sure the material would support the snap fit I designed. On the PCBs, I was really surprised to see how well the silkscreen turned out, as some of my images I added are really small.

If you want to check them out you can use my referral link.

Building everything together

All the parts I used I had laying around, besides the PCBs and the enclosure of course. The most expensive one would be the BQ24230 for charging the battery I had conventionally not used in any other project since I bought them. The most pain was to solder in the USB-C connector, but I guess that's the price you have to pay to be able to charge your project with the cable of your phone.

I would have loved to build more than one console at the moment, especially as I have five more PCBs from PCBWay, but unfortunately I didn't had enough LEDs as well as no second BMU.

Features I added in Hardware (no matter if my code uses them)

I added the option to expand the LED strip if the eight LEDs on the PCB aren’t enough (which, to be honest, they usually aren’t for most games). I exposed the output pin of the last RGB LED, along with GND and VCC (which should be between 3.6V and 4.2V). This allows you to add as many LEDs as you want to the game console—at least until the ATtiny's RAM runs out.

Also because playing alone is boring, I added the theoretical possibility to connect two consoles together. At start I wanted to use a two wire protocol like I2C, but for that, I'd either had to get rid of one of my 3 buttons or use the reset pin (PB5) of the attiny, which would have made it really difficult to change the code after it's first uploaded. So I was forced to use only one pin. Because of that, I wasn't able to implement a multi-console game, as I had no idea how to implement a one wire protocol that either works without master or how the consoles could figure out which one should act as master, especially with the limited memory I had to work with. However, this is something I really want to include into this, my PCB already has a picture for pong across 2 consoles. (if anyone knows how to do this, I'd happily accept help, as my software developing skills are not the greatest)

The Code and the features I did indeed add to this project yet (or thought of adding)

For this Project to save as much precious space as possible, I modified Matthias Hertels OneButton Library, so the stuff I don't need like multiple presses or software debouncing don't take up memory. For interfacing the LEDs I used the tinyNeoPixel library, which is specialized in low memory consumption. Also it comes directly with the AtTiny Core, which is needed to program the attiny with Arduino.

I testet my code before uploading it using the wokwi website, the zip of the wokwi project is attached, with all Debug statements I added. Also because for some reason the tinyNeopixel Library is not supported in wokwi, I was forced to use the Adafruit NeoPixel library for simulation.

As the memory is limited, there is no collection of high scores or such...

Read more »

project.zip

the wokwi simulation as zip, for everyone that wants to use it. I mean I made it so I can as well post it (it will not recieve updates of the code if i make changes)

x-zip-compressed - 27.58 kB - 09/02/2024 at 20:40

Download

Gerber_PCB_AtTiny 1D Spielekonsole_2.zip

the gerber files, so you can also own one of this console

x-zip-compressed - 65.52 kB - 09/02/2024 at 20:39

Download

Schematic_AtTiny 1D Spielekonsole.pdf

the schematic of the game console

Adobe Portable Document Format - 94.18 kB - 09/02/2024 at 20:38

Preview

Körper1.stl

The bottom part of the enclosure

Standard Tesselated Geometry - 215.12 kB - 09/02/2024 at 20:37

Download

Körper2.stl

The top part of the enclosure

Standard Tesselated Geometry - 141.49 kB - 09/02/2024 at 20:37

Download

View all 14 components

  • New Game - Mastermind on ATtiny85

    Leon09/04/2024 at 21:20 0 comments

    Today I just had the best idea for a new game: an implementation of the 1972 published game 'Mastermind'.

    The game


    To put it to simple terms, one player creates a code of 4 different colored pegs and the other player has to guess this code. For this he has 12 guesses (if i remember correctly) and with each guess the first player has to show the number of pegs of right color as well as right position, and the number of pegs that have the right color but the wrong position. For this pegs of two different colors are used.

    My implementation

    As my console has 8 LEDs this fits perfectly onto it. I implemented it as single player game, so the code is randomly generated from, at the moment, 4 colors (green, red, blue and purple). I guess it would be possible to use the remaining 300 Byte of flash memory for a multiplayer version of this game, but I'm not going to try it. For showing the number of completely right colors I used a white LED and for only the correct color it shows orange LEDs.

    The game starts with all red pegs. With 'key2' you can change the color of the currently selected LED, with 'key3' you can move to the next LED (and jump from the last to the first one). With 'key1' you can basically submit you code to the other player (the computer) so he shows the number of rights. At the moment I did not implement a limited amount of guesses, as I have no Idea how i could show the number of guesses a player has left.

    With each guess it's checked to see if you won, and if you did by guessing the code the gamestate changes to won and a new round starts.

    Mastermind
    The first 4 red LEDs, with the green one being the cursor
    Mastermind 2
    All 4 possible colors with two having the right color but being in the wrong place

    Also I reduced the brightness of the LEDs as it was painful staring into them with the previous brightness.

View project log

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates