loading

Did you ever play those impossibly difficult text-based adventures back in the day?

"You find yourself in a dark room, there is a bed, a trumpet, and a can of oil. You are holding a watermelon. What should you do?"

Errrrm... *stuck*

Anyway, I was playing with a 240x64 pixel lcd display and an Arduino when I had a great Christmas gift idea. How about make a simple adventure game, but use multi-choice options instead of a keyboard. (You always had to get the text instruction phrases perfectly right!)

So that's what I did. The gift was really well received! I recently decided to make another and document the process so I could share it with everyone.

So, this instructable will show how to make a simple text adventure game, along with the arduino code.

I used a 240x64 lcd display which utilises the Toshiba T6963C chipset; quite a common display, however the code could be easily modified to use an alternative display.

Step 1: Gather Your Parts and Tools!

Ok, so we'll need the following parts for our adventure game:

  • Arduino Uno / Mini Pro 5v (or compatible)
  • Push buttons
  • Toggle switch (on/off)
  • Project box
  • 240x64 LCD display (T6963C chipset)
  • Wires including an old IDE ribbon
  • 20kΩ potentiometer or a selection of resistors
  • 4xAA Battery holder
  • Solder, glue etc
  • Coffee

Also we'll need the following tools:

  • Soldering iron
  • Drill & multi-tool (like a Dremel)
  • Glue gun
  • Other basic hand tools, screwdriver etc
  • USB2Serial interface if you use a Mini Pro

Additionally, we'll need the code for the game: See zip-file link at the bottom of this step.

For this adventure game I used a 5v Arduino mini pro, as they are so cheap. A standard Uno would do the job fine though, I built the prototype with one.
I bought some T6963C displays cheap from a manufacturer in China, you can get them in various colours.

Now that you've got everything you need, drink your coffee then move onto step 2.

Step 2: Cutting and Drilling

I used a project box I found in Maplin, it's a bit on the large side and would have preferred a shallower box, but it does the job.

I measured bezel on the LCD and used a pencil to mark where I should cut. If you want a perfect finish, then cut slightly too small and use a file until the display fits nicely. I found that the plastic melts very easily so take your time and don't set the tool to max speed!

The holes for the buttons are easy enough, I used the multi-tool again to drill pilot holes then used a regular drill with metal/plastic bits to make them larger.

I had to trim a little of the top corners of my display so that it would fit in this particular box.

You can fit your buttons and switch now if you like, and use the glue gun to stick your display in position.

Clean up all that mess and bits of plastic in the kitchen before the wife gets home!!

Now grab another coffee and move onto step 3.

Step 3: Soldering

If you're using the Arduino Pro Mini 5v, then solder a little header for the programmer.

The buttons; solder one leg of the buttons to ground. The other leg of the buttons as follows:

Button 1 : Arduino Pin 10
Button 2 : Arduino Pin 11
Button 3 : Arduino Pin 12
Button 4 : Arduino Pin A4

As you can see in the photos, I looped the ground wire across all of the buttons, then to the Arduino. I used a little piece of veroboard for the various ground connections just to make it tidy, but you could just solder them all together and tape it up.

Then the toggle switch; solder one leg to positive on the battery holder, and the other leg (or middle leg if it's an On-On switch) to the 'raw' pin on the Arduino Pro Mini. If you're using an Uno, then you'll have to make a little power adaptor.

On the back of the display, there is an interface header, 22 pins at 2.54mm pitch. I used an old 40-way IDE cable and just cut off the unused 18 wires of the ribbon as you can see in the pictures.

This is where you should connect up the pins from the display:

Display - Arduino

01 - Ground
02 - Ground
03 - 5v VCC
04 - Display pin 20 via resistor (see below)
05 - A0
06 - A1
07 - A2
08 - A3
09 - Not connected
10 - Reset
11 - 2
12 - 3
13 - 4
14 - 5
15 - 6
16 - 7
17 - 8
18 - 9
19 - 5v VCC
20 - Display pin 4 via resistor (see below)
21 - 5v (backlight)
22 - Ground (backlight)

Between display pins 4 and 20 you need to add a resistor to control the contrast of the LCD. Ideally a potentiometer could be used; I didn't have one to hand so I played about with a variety of resistors and finally used 10kΩ and 4.7kΩ resistors in series like you can see in the picture.

It's during this step that any mistakes are going to happen. Just double check each connection.

Time for a break. Get more coffee, and some chocolate too if you fancy a snack.

Step 4: Software and Finishing Up!

Download the Zip file from step one (if you haven't already).

In there you'll find two folders, "libraries" and "TextAdventure_T6963C"

Inside the libraries folder there is the library for the display, pop that in your Arduino libraries folder.

You can save "TextAdventure_T6963C" wherever you usually save your Arduino projects. When you open the project, you will notice that it contains two files, TextAdventure_T6963C.ino (the main program) and Strings.h (the text strings for the game).

Now you should be able to open your Arduino software and upload the code to your Arduino.

Whist programming/testing and playing with the code, it will all run from the programmer/usb power, so you can disconnect the batteries.

Assuming your soldering is all good and it works, you can glue/tape your Arduino into the case and tidy up the wires. I used double sided tape to stick the battery clip to box lid.

That's it. Hope you've enjoyed reading this Instructable, and if you decide to make one of these games, I hope you enjoy it!

The video here is of the game I gave my friend at Christmas, exactly the same but with a blue screen and added a Christmas message when it was turned on.

Possible Improvements:

With only 32k of flash and 2k of sram, I was pretty much at the limit of the Arduino Pro Mini. A few things could be done to remedy this:

Use an Arduino like the Zero (256k flash and 32k sram)
Use a raspberry Pi (overkill?)
Add an SD-card reader and store games on SD cards?

<p>Hey,</p><p>Made an adapted version of this - thanks for all the work you put in!!</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/o8cVagoBdSk" width="500"></iframe></p>
<p>What display did you use for your project?</p>
<p>I used a T6963C, They're not the cheapest of displays and require a lot of wiring, but I got one out of a broken MF/HF radio at work, after I built a prototype I ordered new ones from here:</p><p>http://www.buydisplay.com/default/catalogsearch/result/?cat=&amp;q=T6963C</p>
<p>That's awesome! I joined the kickstarter for an Arduboy (hopefully not long to go now until delivery).</p><p>Was it much work to change the code for that display? Like what you did with the option selection ;-)</p>
<p>Thanks! A big part of the work was re-formatting the text to fit into 18 lines instead of 8, I'll E-Mail the source to you...</p>
<p>Looks great Uxe! I want to create something similar. I have a 128 x 64 LCD display and a arduino uno? do you think that would work? Would you be willing to share your code with me? </p>
<p>I used a 160x144 LCD, so my code probably isn't the best place to start for working with a 128x64 LCD. WarmCat's original code or dadecoza's code for a 2 row / 16 character LCD could be a better starting point to fit inside of 128x64 pixels? Do you know the exact model of your LCD? Then we could work out which library to use for displaying text...</p>
<p>Hi,</p><p>What a fun game!</p><p>I also adapted it for the 16x2 lcd <br>display. Having to go through the code I can really appreciate the <br>amount of work you had put into it. :)</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/4AB9z7Vc-Ic" width="500"></iframe></p><p>Source: </p><p>https://github.com/dadecoza/TextAdventure_1602</p>
That's really cool :-D I'm glad that you like it, and it's great that you've converted it to a common display. <br>I bet it must have took some time to convert it though!
<p>It did take some time but that was half the fun. I wrote a quick perl script to parse your Strings.h and do the 16line word wrapping to create most of the new Strings.h file, still took a few hours to do the mappings and update the game code.</p>
<p>Please forgive the crummy case, my goal was to make this with spare parts I already had. Thanks for the Instructable and the code! I did change the menu numbers to R,G,B, and Y to correspond to my buttons. I may write a new story and post it here with your permission. Thanks again! </p><p>Also, unfortunately I couldn't find a screen with a backlight but scored this non-lit on on Ebay for $5!</p>
<p>Thats awesome! Great idea using coloured buttons :-D Did you enjoy the story?</p><p>Yeah change the code and stuff as much as you like, would be great if you made a new story and instructable; then I could play it on my device.</p><p>It's right at the limit of memory on the arduino, I started getting weird errors when it was only slightly larger. Maybe the new Arduino zero would be a good idea, assuming the code runs on it ok.</p>
I did enjoy the story! I could try it on my LinkIt One as well. It has a lot more more and is basically a direct swap for the Arduino. Though with the extra features, it's a bit overkill. But then again, I could connect it to WiFi and allow it to pull down new adventures from Github! Lots of possibilities!
<p>Regarding the case; it would look great in a case similar to what you got cut for your Pandora clock. (awesome btw)</p>
I've just learned how to SAY arduino, and I'm wanting to make this! Ah, memories of Zork. Plus, I love coffee! Really great Instructable!
Thanks :-D yeah get one of those displays and have a go!
<p>Nice project. :) Regarding your improvements - I would go for a Raspberry Pi A+. You get (almost) unlimited storage, and it's even cheaper than the Zero. Really cool project, would love to see more of it. :)</p>
<p>Thanks! Ah yeah the Pi A+, I could add one of those 2&quot; colour lcds and have little pictures for the various areas in the game too :-)</p>

About This Instructable

4,805views

152favorites

License:

Bio: Electronics Tech working with Automation/Instrumentation. I love to invent stuff and play with retro electronics.
More by WarmCat:Text-Based Multi-Choice Adventure Game 
Add instructable to: