aka LED Ladder Display Game System.
An Attiny-85 outfitted with hardware and software to play action packed "video" games, on a in-line LED display.
It has a multiplexed 12 LED ladder display, and supports up to 6 button inputs and an optional audio output.
It is packed with 4 games of skill, with multiple difficulty levels and some variations (updated to 16 games, when used with an ATMega MCU).
Step 1: Major Componets
I built my project modularly (two separate assemblies). A main Display sub-assembly; which can be used by itself stand-alone. And a Button input sub-assembly. That way I can use the button or the display assembly again in another project. This also allows for flexible mounting options.
I also brought out the control line to a pin-header for the LED ladder assembly so I could utilize an Arduino Nano (or an Uno), to develop software for it as well as use it in other projects. A Digispark will not work due to the other components on its circuit board.
I chose to use the same pin assignments for the LED ladder as in earlier
instructables to make it easy for those who already have such a hardware implementation to utilize the software in this instructable, even though I did not find the assignments made for the clearest logic in the software.
The two lines between the modules is PB4 and ground. As all that is on the multi-button assembly is resisters and switches so it is not polarity dependent, and reversing the connection matters not.
With the support of more buttons a greater variety of games (or applications) can be implemented. Two of the games in this instructable is best played with two buttons. The four main buttons can be used to directly access an associated game. Soon I will implement a game which depends on the use of all four main buttons.
This project uses up to six buttons. Four main ones BTN 1-4, These buttons can be individually detected even when any two of them are pressed simultaneously. The other two are special buttons, first there is the equivalent of the single button in earlier projects which makes a hard connection between the PB4 input to ground, I call this BTN0, or ESC as this switch can always be detected and will block out detection of any of the others. The other special key is the Function-Key, if pressed when BTN 0-4 are pushed it can be sensed and used to change functionality.
In this skill game sketch I use:
- FncKey+Btn1 return to menu mode
- FncKey+Btn2 advance difficulty level (if at highest go back to lowest)
- FncKey+Btn4 instant Pause (hit any key to un-pause)
- FncKey + Btn 0 or 3 are undefined.
Step 2: Parts List
- LEDs, red,yellow,green and blue like these
- PCB boards similar items you may have to buy a larger board, and cut it to desired size.
- pin dip socket similar items
- Attiny-85 chip
- button switches used: 12x12x8mm and 6x6x6mm PCB Momentary Tactile Push Buttons
- buzzer 5v, active type
- a Popsicle stick
- 2.54mm pin header strip
- 30 ga wire and wire-wrap tool http://www.ebay.com/itm/351798901037
the above link is to wire that is more like 36 ga. I wish I knew of such a deal for real 30 ga. wire
Step 3: Construction Highlights
On the main board assembly I electrically have the same as other earlier LED ladder projects, which you may want to refer for further basic construction directions https://www.instructables.com/id/Attiny-85-Led-Lad...
I however do not use an exterior pull up resister on the analog input A2(PB4), also I use Red,Yellow,Green and Blue LEDs, instead of all one color, which is desirable for some of the games I created for this hardware.
Here is the I/O assignments as expected by the attached software sketches:
Project MCU AT-85 Uno/Nano Names name pin# brd name --------- ---- ---- --------- Red L1-3 PB3 2 D-11 Yel L4-6 PB0 5 D-8 Green L7-9 PB1 6 D-9 Blue L10-11 PB2 7 D-10 Ain PB4/A2 3 A-2 Audio PB5 1 D-3
The one significant difference is that I have two buttons wired to PB4. The first goes directly from PB4 to ground but with no external pull up resister (I call this BTN0). I also have a button switch (which I call BTN1) connected with a 75Kohm in series to ground. This main board can be used without the "Button" assembly board, but with some limited functionality.
The current limiting resisters going to the sets of LED should be chosen based on the brightness of the different color LEDs you use and how bright you want them. I ended up with 91 Ohms for the red set, 75 yellow, 430 green and 150 Ohms for blue. These values may seems low, but remember the leds are multiplexed (generally on much < 100% of the time)
I used 3mm leds and spaced them apart a little bit. I had the legs of the LED straddle a Popsicle stick. This way they all stood up the same amount and above all other components. I am intending, at some point, to mount the unit with just the LEDs protruding through a frame.
I chose to wire-wrap the led interconnections. Without a special printed circuit board this is easier to do than soldering in tight places with lots of interconnections; does not tend to produce shorts and is easier to rewire in the case of a mistake. With all the currents in and around the micro-controller in the milliamps 30 ga wire is plenty sufficient.
Buttons and related resisters:
I devised a unique configuration (sort of a double Y) of resisters and buttons, such that the software could discern individual and dual button presses (theoretically any combination of these four buttons can be identified). I tried several configuration with a multitude of resister values in a spread sheet looking for the best configuration, then simulated them in software having it try all possible resister combinations to find the set (that I am using) which would produce the maximum of minimum difference of analog readings between any & all single and double button presses. I arranged them so that Btn1, Btn4 and Btn1+4 in particularly were distinct.
Refer to Diagram of button network above.
You need to cover up all wiring which inter-connects to PB4 (and possibly switch contacts & resisters) with electrical tape, hot glue or something else which does not at all conduct, as a mere mega-ohm resistance will throw off the ability to determine which switch(es) are pressed; and any such contact you make while holding an assembly would do that.
Later associated Instructables:
Step 4: Further Options and Notes
Optional Audio output
The optional audio output uses PB5. I connected a 5v buzzer, in series with a 150 Ohm resister to limit its otherwise loud annoying output. I recommend you use 50-200 Ohm. One could parallel the buzzer with a cap (2-10uf) to make it less raspy, or use a 10mm driver 32 Ohm speaker broken out of a set of cheapy stereo ear buds, instead of the resister and buzzer. I like it, for game sounds, better as I have it.
By default the Attiny-85 uses PB5 as a reset, effective means the audio would work but it will not have an ill effect on any other operation. When using a Nano or Uno the audio will work (coming out its D3) . To get audio with the Attiny you will have to change the internal pin configuration so the software can use PB5 as an output. There are significant ramification in doing this; please refer to these:
Generally during game play a mistake or failure will invoke a chirp or short raspberry sound. There is a congratulatory tune played when you complete a level or win, like at ping-pong. I find that having accompanying audio really increases to joy of play.
Alternate game controller type buttons
For my grand kids, who are rough on equipment, I made durable separate buttons, Btn1 and Btn4, on the end of long lead wires. See photo. I mounted the buttons in make-sift grips; with a 75Kohm inline with Btn1, and a ~37Kohm inline with Btn4. In series with Btn4 I actually used a 36K, a 33K or even possibly a 39K could be use. With external plunger buttons in mind, it would be a good idea to have a separate set of header pins, for connecting external hand-held buttons seen as Btn1 and Btn4.
Quality power supply needed
For a power source you can use the USB 5v output of a PC, tablet, wall charger, a power-bank or 3.7 Li battery directly.
I found that when powering the unit from some USB chargers and several USB power-banks that I would notice flicking and occasional miss behavior and even resets. If you experience this find a power source with better regulation, otherwise adding a large (100-1000uf) capacitor across +V to ground may help.
I have also included a test program to help validate and debug your hardware. The code is a work-in-progress, and is in great need of being cleaned up. I hope to get to that, but mean while It should serve your needs. I have recently only used it with a Nano driving the display and keyboard assemblies. You can use most any button to select items from the menu mode. To exit a demo/test again hit most any button. To exit the button test (#4) hit FncKey+Btn1 or hold down the EscKey (grounding PB4), or recycle power.
Due to differences in MCU internal resistances and resistor tolerances you may need to do some adjustments so that all single and dual button presses are detected correctly. To do this use test-4 (to select this refer to description of menu operation below) of the test program. Note that I didn't use an external pull-up resister as I have further planed uses for the PB4 input which are incompatible with any pull up.
Step 5: Software Overview
The sketch LadderGames.ino implements four games including some alternate versions.
The sketch can be downloaded and ran from a ATtiny-85, Nano, Uno etc. To program it into an Attiny chip see: https://www.instructables.com/id/Program-an-ATtiny... and/or to program your ATtiny-85 chip: https://www.instructables.com/id/How-to-program-th...
Change the internal clock of the ATtiny85 to 8MHz, as the performance is desired for the game play. Refer:
This sketch should be backwards compatible with most earlier ATtiny-85 led ladder projects, without change, but will have some limited functionality.
On start up there is a health check in the form of a sweep across the LEDs and a set of beeps. Then it goes into main menu mode. Each set of LEDs of one color are lit for a couple of seconds in succession. A game is selected by pressing a button while an associated set is lit, game 1: Red, game 2: Yellow, game 3: Green, game 4: Blue. While in menu mode Btn2, Btn3, Btn4 can be pressed to go directly to games 2,3,4 respectively. Once a game has been selected you will need to indicate the variation you want. For each variation available a set of colored leds will flash. Simply press a button on the one you want. The variations, “versions”, for each game are further described below.
Version one of all four games can be played with a single button. Either one wired between PB4 and ground (Btn-0) like in earlier LED ladder instructables, or with a switch which connects a 75k load to ground (Btn-1). Either of these will do in games when the instructions speak of a non specific button press.
To exit any game you can use FncKey+Btn1, hold EscKey (aka: Btn0) down for 1-2 seconds or cycle the power.
Step 6: Game Play
Game 1: Push-It
This is an adaptation of my 'Push-It' game from one of my earlier instructable
The goal of the game is to push the blink count and the number of lit LEDs to as many as possible. Push-It starts off with a number of flashes, which will then repeat. If you push the button after the last flash in the series and when an additional one would potentially exist the next LED will light and the flash count will increase by one. But if you 'push' before or after the time period of a would-be additional flash instead the count of flashes in the set will be reduced.
Every time you manage to increase the flash count the level of difficulty is increased as the timing speeds up a little, making it harder and harder to get up to higher flash counts.
The current count number is stored into EEPROM memory for restarting at the same level later.
Game 2: Ping-Pong
Great (albeit the only) two player competitive game herein; where the ball (single blip of light) goes from one side to the other, faster and faster, each time it gets 'hit' back.
I first implemented this single row of lights game across the front panel button-lights of an aerospace super-mini computer in the 1970s.
To hit the ball back and forth the appropriate paddle must hit (button pressed) it when it is in the end position (last LED). The first side to miss loses, and the lights on the winning side flash.
There is two variations, one requiring only one button (Btn 0 or 1), which will hit the ball at either end; and a second version, is for two person head to head, which requires two buttons; button 1 on the left side and button 4 or 0 on the other. The use of Button 1 & 4 is preferred, as they will not interfere with each other; each can be hit to return the ball from its end no matter the state of the other button.
The winner of a rally is always the server for the next.
Game 3: Shooting Gallery
Shoot all the targets (lights) to complete a level. In each higher level the action is faster.
There are two versions; one where the site is fixed and the targets move and another where the site moves and the targets are still. In each case a hit knock out a target light; and a miss causes a target to pop up. When a target is in the sight the sight lights up brighter, otherwise it is dim.
In version one the sight starts at the left (bottom) and scans right. In version 2 the sight is fixed in the middle while the target move across right to left. By looking at the code there are ghostly versions 3&4 which could be activated, but you put your own well being at your own risk.
Game 4: JumpMan
The idea is that you're running through a game level where objects come along which you have to jump over, as you progress they come faster. In another game version there are also over-head objects you have to duck under.
In version one there are only objects to jump over. To jump you must press the button when the object gets to the last cell on the left; which brightens when this occurs. To jump 2 or more consecutive objects you have to jump (press) on the first and hold down the button for the rest.
In version 2 over head (flashing) objects are added. Those are jumped by 'jumping during the cell prior to it and release while it is in the end cell. Only one overhead can flash at a time, so once one has passed you may see another (not flashing before) bare down on you. There will never be consecutive overheads but they can be adjacent to one or more jump (boulder type) objects.
In game version 3 you must, get to, use a separate button for the overhead objects (Btn- 2,4 or 0 your choice); jumps then require Btn-1.
Once you have managed past four more object(s) than you failed at, you advance in level; there is an audio and visual congratulations, then a resumption at a higher rate of speed. Getting by a set of consecutive objects counts the same as one individual object.
I advise you to print out the about games' rules of operation and reread them before you play a game you have not recently played. Otherwise, you can frustrate yourself; thinking that the game is not operating properly when it fact it is, but you and the game have different ways and expectations. I, myself, have fallen pry to this more than a couple of times.
Step 7: Update, More Games
I have devised more games that utilizes this hardware. Check them out and have fun:
Dec. 2016. Now, at the end of the above link, there is a unified version of code including all 12 games.
Feb. 17, 2017: Here is the latest game set for this project, now with 16 games (sketch below). This will run on any MCU implementation with 32KBytes of flash program memory. All though any one to 3 or 4 of the 16 games can be put into a ATtiny. I recommend using the Nano 3 arduinos. The latest 4 games added are 'Le Mans' racing, 'Spray' head to head spray painting contest., 'PIG' basketball hoop shooting, 'BiFunc' a binary operation quiz game.
With greater and more diverse playing of these games improvements to their play-abilities, enjoyment for all level players, is possible. I think there is a lot of room for improvement in Le Mans racing via track layout design and game timing.
I have, written up, about 10 more activities/games/functions, some of which I hope to make available around fall 2017.
Also these one line games can be modified for a 2 line 2x16 LCD display, with one line of game objects and another for some text. I have done a little of this, but, as I am backed up with projects as far as I can see, I don't know when or if I'd get a round to it. So if anyone is motivated to adopt and optimize these games for a 2x16 LCD please share with me and others.
I hope many take the time and . . . ENJOY these games.
Group game: 1– Red 2- Yellow 3 – Green 4 – Blue 1 red PushIt PingPong ShootEmUp JumpMan 2 Yel QuickDraw Tug_a_War Chicken Hot_Hands 3 Grn Le_Mans Spray PIG BiFunc 4 Blu SimonSays Whack_Mole Sea_Hunt Flip_d
Sep. 2, 2017: Improved work-ability with old dirty noisy external joystick buttons, in head-head game (group 2).
Dec. 13 2017: Improved handling of button bounce and measurement settling, fixed minor issues.
I had tried using a capacitor on the button analog input line but to be effective it resulted in slow measurement settling producing false level identifications or the software waiting so long that fast game action was compromised.
Apr 2018: I have found that 5/8" Compression Couplers make great bodies for external plunger style buttons. As my kids like using a pair of these, I added header pins so as to easily connect two of them (as Btn1 & Btn4).
Note that I created another project, last October, that is built on this instructable's hardware. It is in the Halloween spirit and can be a lot of fun, especially for the kids. Instructable: Ghostly-Psyche-Influenced-Devices