Build Your Own Escape Game Artefacts! Part 5

Image

Have you ever wanted to build your own escape game artefacts using low voltage electronics? Look no further! In the upcoming months, look out for a short series of articles on how you can approach creating small, but effective artefacts for your own game designs.

Previously…

In part 4, we have our basic countdown timer product. Part 5 will look at potential bonus features you can add to your product to make it even better!

You Will Need

Fundamental Equipment

1x Arduino Uno (or open-source copy)
1x Arduino Uno USB connector
A laptop or desktop computer
A download of the Arduino IDE
A power adapter for the Arduino Uno (see part 1 for guidance)
4x male to female dupont cables (1x red, 1x black, 1x yellow, 1x blue)
2x male to male dupont cables (1x black, 1x brown)

Specific Equipment

1x TM1637 4-digit, 7-segment display timer – (Look here for examples)
1x Emergency stop button with locking mechanism when pressed – (Look here for examples)

Extra Feature #1 – Stop & Reset Button

Picture this. You’ve got 5 seconds left on the clock in an escape room, and you’re about to stop the clock just in time by hitting a big red switch. Sounds amazing right? Let’s make it.

Red – 5V -> VCC
Black – GND -> GND (Timer)
Yellow – Pin 2 -> CLK
Blue – Pin 3 -> DIO
Black – GND -> Button Pin
Brown – RESET -> Button Pin

If this diagram looks unfamiliar to you, please revert to the original one in part 4. This is merely an addition to that. Depending on which type of emergency stop button you have purchased, it might have either 2 or 4 pins to connect. This will be a case of trial and error; swapping the dupont cables to different pins to achieve the desired result.

The desired result will be the timer freezing once the button is pressed and subsequently, locked in (again I stress, buy a locking mechanism button!), and when the button is twisted to unlock, the timer should reset back to 60:00.

Extra Feature #2 – LOSE At The End Of The Countdown

Picture this. (This one isn’t so fun). You’ve got 5 seconds left on the clock in an escape room and you’re about to stop the clock just in time by hitting a big red switch… but you don’t make it quick enough and in place of the timer, you see LOSE. Nooooooooooooooooooooooooo!

Sounds um, less amazing…right? Let’s still make it.

Included in the <TM1637Display.h> library which we are already using for our timer, you can add up to 4 characters on the display before or after the countdown.

Here, I will show you how to show LOSE, once the countdown has reached 00:00.

Above, is a diagram of the 7 segments a single display character can hold, alongside a letter (A-G).
First off, we need to work out what segments we need to display the word LOSE. Feel free to work it out yourself, or look below for the solution.

L = Segments D, E & F
O = Segments A, B, C, D, E & F
S = Segments A, C, D, F & G
E = Segments A, D, E, F & G

Now that we have our segments worked out per character, we need to:

  • Declare these in the code we already have
  • Create a function called void lose()
  • Add a condition for it to show once the display shows 00:00

Declaring The Segments

Add this code in your // Display function:

const byte LOSE[] = {

SEG_D | SEG_E | SEG_F,
SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F,
SEG_A | SEG_C | SEG_D | SEG_F | SEG_G,
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G

};

void lose()

In between the void setup() and void loop() functions, add the following:

void lose() {
display.setSegments(LOSE);
delay(1000000000);
}

delay(1000000000) – holds the LOSE message on display for approximately 277 hours, when activated – ie: long enough!

Adding The LOSE Condition

In your void loop() function, add the following after the first of 3 right curly braces (}):

else
lose();

Test Your Code

Now is time to check your code is error free. Click on the tick in the IDE. If that is error free, now click the right facing arrow button (with your Arduino Uno connected to your computer) to load your updated code in. You may want to temporarily change your timeLimit to 10 seconds for swifter testing.

If you receive an error at any point, please use my troubleshooting tips in part 4 as a starting place to fix your bug.

If you are feeling brave, you could even try to change LOSE to show a different set of characters – eg: STOP.

If you are feeling even more brave, try putting a 4 character message before the countdown begins.

End Of Part 5

That’s all for now, for the time being. I hope this has been fun for you to build! I’ll return later this year with a new project, but for now, take care!

Build Your Own Escape Game Artefacts! Part 4

Image

Have you ever wanted to build your own escape game artefacts using low voltage electronics? Look no further! In the upcoming months, look out for a short series of articles on how you can approach creating small, but effective artefacts for your own game designs.

Previously…

In part 3, we created real code out of our pseudocode and placed it into our IDE. Part 4 will involve testing both the code and the connections between the Arduino Uno and the TM1637 timer component.

You Will Need

Fundamental Equipment

1x Arduino Uno (or open-source copy)
1x Arduino Uno USB connector
A laptop or desktop computer
A download of the Arduino IDE
A power adapter for the Arduino Uno (see part 1 for guidance)
4x male to female dupont cables (1x red, 1x black, 1x yellow, 1x blue)

Specific Equipment

1x TM1637 4-digit, 7-segment display timer – (Look here for examples)

So Far…

  • We have planned our objective:

We want to code a timer that counts down from 60:00 minutes to 00:00 minutes.

  • We have designed our coding workspace (IDE) to have 4 functions or ‘containers’.

Library, Display, void setup() and void loop().

  • We have written our code in the workspace.

Next, we will connect our hardware components, power up and test the artefact!

Setting Up The Hardware

Go ahead and use your dupont cables to connect the Arduino Uno and the TM1637 display timer like so.

Red – 5V -> VCC
Black – GND -> GND
Yellow – Pin 2 -> CLK
Blue – Pin 3 -> DIO

Make sure the dupont cables are snug when connecting. Next, take your USB connector and connect the one end to the Arduino Uno and the other into your computer. The power on should light up on the Arduino Uno; the computer may take a few minutes to download any required drivers, and should let you know when it is done.

Testing The Code

Open up your IDE with your code from part 3, and go to
Tools > Board > Arduino/Genuino Uno
then
Tools > Port > COMx (Arduino/Genuino Uno) – The x will be a number of the Arduino’s choice.

Next, click the tick button, right below the file option. This will check the code for any errors.
If you have any errors, you will need to troubleshoot them. Two good starts to this would be:

  • Checking that your code is identical to that presented in part 3.
  • Pasting the error description into google and see if any of the forums have already answered/resolved the issue you have.

Should the code be error free, it should show a message starting

Sketch uses x bytes (x%) of program storage…

Once you see that message, go ahead and click the right-pointing arrow button, next to the tick button. This will transfer the code to the Arduino Uno and subsequently, the TM1637 display timer.

Should this be successful, the TM1637 timer should light up and start counting down!

Testing The Countdown

One other thing I suggest testing, is if the countdown stays at 00:00, when counted down entirely; ie: no further counting, or no counting up for that matter!

There are two ways you can do this. The easiest but far longest way is to wait until the timer has counted down from 60:00 then check its status. The better way is to temporarily change the timeLimit to 10 seconds, then check. How to do that however, I’ll leave for you to figure out.

Remember, if anything isn’t doing what it should be doing, try my two suggestions for troubleshooting above.

Testing The Power Adapter

Whilst the USB connection powers the Arduino Uno perfectly well, it is highly unpractical to have the artefact permanently connected to a potentially large and bulky computer. Here would be a good time to plug your power adapter (remember to take out the USB connection!) into the Arduino Uno and see if the desired results are the same.

End Of Part 4

At its most basic (but certainly useable), you have your escape game countdown timer artefact programmed and working! Nicely done! Part 5 will look at bonus features you can add to the countdown timer for further usability.

Thanks for reading and see you next time!

Build Your Own Escape Game Artefacts! Part 3

Image

Have you ever wanted to build your own escape game artefacts using low voltage electronics? Look no further! In the upcoming months, look out for a short series of articles on how you can approach creating small, but effective artefacts for your own game designs.

Previously…

In part 2, I spoke about the Arduino Uno microcontroller and getting to grips with the IDE. Part 3 focusses upon evolving our psuedocode into real code.

You Will Need

Fundamental Equipment

1x Arduino Uno (or open-source copy)
1x Arduino Uno USB connector
A laptop or desktop computer
A download of the Arduino IDE

Specific Equipment

1x TM1637 4-digit, 7-segment display timer – (Look here for examples)

So Far…

  • We have planned our objective:

We want to code a timer that counts down from 60:00 minutes to 00:00 minutes.

  • We have designed our coding workspace (IDE) to have 4 functions or ‘containers’.

Library, Display, void setup() and void loop().

Next we will look at what each of these functions will contribute to the objective, alongside adding some real C++ code to it!

Library

Libraries are files embedded to the IDE that add more functionality and ease of use. For our objective, we will be using just one library file; the TM1637Display.h by Avishay Orpaz. This file includes a series of commands that we will use in our code, to allow the Arduino Uno tell the TM1637 display timer what to display in real time.

First off, we need to pull the file into our workspace. We can do this by selecting

Tools > Manage Libraries…

Next, we need to install the latest version (v1.20), make sure you choose the correct file, I’ve highlighted below to help you navigate.

Because I’ve already installed it, there is no install button for me. One for you, should appear in the right hand corner once you hover your mouse over. Once this has installed, we need to return to our workspace and under the // Library comment, type in:

#include <TM1637Display.h>

This now sets us up ready, to tell the Arduino Uno (and subsequently the display timer), what to do.

Display

There are 2 things we need to set up in this Display function.

  • Declaring the clock and data in-out (DIO) pins.
  • Declaring the length of the timer (60:00 minutes).

If you look on the back of your TM1637 display timer, you will notice that you will have 4 pins to connect via dupont cables, to the Arduino Uno; CLK, DIO, VCC and GND.

CLK = Clock, DIO = Data in-out, VCC = Power, GND = Ground

Power and ground pins don’t need to be declared, just the clock and DIO pins. In other words, we need to tell the Arduino Uno what number pins on the digital side (see The Arduino Uno from part 2) of the microcontroller will be connected, to the CLK and the DIO. As a rule of thumb, we don’t use pins 0 and 1; they are for transmitting and receiving signals, and is best not to interfere with them.

For this exercise, we are going to declare pin 2 as the CLK and pin 3 as the DIO. Return to your workspace and under the // Display comment, type in:

const int clkPin = 2;
const int dioPin = 3;

TM1637Display display(clkPin, dioPin);

const = Constant, ie: non-changing
int = integer, the number of the pin (eg: 2)

Now that you have successfully declared your CLK and DIO pins, next; we will declare the length of the timer. It is to be pointed out that whilst the timer will display in minutes and seconds, the length of time in the IDE must be declared in milliseconds.

Return to your workspace, and underneath your CLK and DIO declarations, type in;

unsigned long timeLimit = 3601000;

unsigned = positive value numbers only, prevents the timer from going past 00:00
long = a number with a large value

3601000 milliseconds = 60 minutes and 1 second. The reason for the additional second is that it takes 1 second for the TM1637 display to power up after the Arduino Uno does.

void setup()

There is only one thing to set up in the void setup() function; brightness of the TM1637 display.

Within the void setup() curly brackets, type in:

display.setBrightness(4);

void loop()

Finally, we will add the code to operate the meat of the artefact; the countdown mechanism.
This will be fairly larger in volume, compared to our current codebase.

Within the void loop() curly brackets, type in:

unsigned long timeRemaining = timeLimit – millis();

while(timeRemaining > 0) {
int seconds = (timeRemaining / 1000) % 60;
int minutes = timeRemaining / 60000;
display.showNumberDecEx(seconds, 0, true, 2, 2);
display.showNumberDecEx(minutes, 0b01000000, true, 2, 0);

if(millis() < timeLimit) {
timeRemaining = timeLimit – millis();
}
}

I appreciate that this may look confusing and alienating, so I’m going to do my best here to relay that code into pseudocode.

unsigned long timeRemaining = timeLimit – millis();
This is declaring a large, non-negative, real-time number called timeRemaining which is equal to the timeLimit (which we’ve already declared) minus the time passed. Ie: The value of timeRemaining will reduce by one second, every second and will show on the display.

while(timeRemaining > 0) {
Whilst the timeRemaining figure is larger than 0

int seconds = (timeRemaining / 1000) % 60;
This is declaring the seconds part of the timer as an integer and is equal to timeRemaining divided by 1000 milliseconds (1 second). The % 60 prevents the timer from using a number in the seconds part of the display that is equal to or larger than 60.

int minutes = timeRemaining / 60000;
This is declaring the minutes part of the timer as an integer and is equal to timeRemaining divided by 60000 milliseconds (1 minute).

display.showNumberDecEx(seconds, 0, true, 2, 2);
display.showNumberDecEx(minutes, 0b01000000, true, 2, 0);
These are commands to tell the TM1637 display how to show the timer to us humans in a way that is readable.

if(millis() < timeLimit) {
timeRemaining = timeLimit – millis();
If there is more than 00:00 on the display, remove 1 second off the timer, per second.

End Of Part 3

Next time, we will be connecting the Arduino Uno to our TM1637 display timer and testing out our code!

See you next time and thanks for reading!

 

READ PART 4 HERE

Build Your Own Escape Game Artefacts! Part 2

Image

Have you ever wanted to build your own escape game artefacts using low voltage electronics? Look no further! In the upcoming months, look out for a short series of articles on how you can approach creating small, but effective artefacts for your own game designs.

 

Previously…

In part 1, I spoke about the fundamental equipment required to create your own escape game artefacts. Part 2 focusses upon the Arduino Uno microcontroller and getting to grips with the IDE; ready for creating an automated countdown timer.

 

You Will Need

Fundamental Equipment

1x Arduino Uno (or open-source copy)
1x Arduino Uno USB connector
A laptop or desktop computer
A download of the Arduino IDE 

 

The Arduino Uno

Above is a diagram of the Arduino Uno with three rails and a button in the top left-hand corner. The rails consist of a set of pins that can have dupont cables inserted into them.

Red – Power – This rail powers any components that are connected to the microcontroller, such as a LCD display or an electronic lock. Power can be distributed either via 5V or a lesser 3.3V depending on the component you are using. GND or ground is also important. In its simplest term, the 5V/3.3V pins are positive and the GND pins are negative, you need both for a component to power up.

Yellow – Digital – These are signal ports and via user code in the IDE, determines what they do for a component. For example, an LCD display would usually need two digital pins; one to display the clock numbers and one to process data in and out (DIO) via the microcontroller. This will be covered further in part 3. There is also a spare GND port on this rail should you need it; serving the exact same function as the GNDs on the power rail.

Blue – Analog – These can be substituted as spare digital pins and will work just as well. Their main use however, are for components that have more complex actions than just on and off. For example, a radio dial which could have multiple potential outputs, compared to an on/off switch, would be more appropriate for it to be patched into the analog rail. For the time being however, we will not be using this rail for our countdown timer.

Green – Reset – Probably the most important feature on the microcontroller. Pressing it resets the board and starts the code from its beginning. The equivalent of turning it on and off again without killing the power source. 

 

The IDE

 

As mentioned in part 1, the IDE is your workspace to tell the microcontroller exactly what you want it (and any connected components) to do. A new file will always show two functions: 

void setup() – a place to put any code, to run once at the beginning of power up.

void loop() – a place to put the main code, ie: what the microcontroller (plus components) will do.

These two functions will be the crux for our countdown timer artefact. Furthermore however, there are two more functions that we will be adding to complete the codebase; a library function and a display function.

 

Pseudocode First, Real Code Second

Before we start coding anything, we need to create a plan of what we want to code, then we can decide how we are going to do it. The what is best done as pseudocode first, in other words; plain English. We need to write down in clear sentences/bullet points, what our objective is and then, how we plan to do it. This step is extremely important, as it prevents misleading into unknown or unrequired territory, alongside saving time in the long run. 

First question is: what is our objective? Easy, I’ll provide this.

Objective: We want to code a timer that counts down from 60:00 minutes to 00:00 minutes.

Next, we need to consider what functions we are going to use in our code.
If you look in The IDE section of this part, you should find them.

Functions to use: library
                            display
                            void setup()
                            void loop() 

Think of these four functions as containers. We need to fill these four containers with code correctly to achieve our objective. 

Now, we can provide space for those four functions in our IDE workspace. 

 

Commenting Code

In your IDE workspace above void setup(), type // Library – you will notice that the text Library has gone grey. The // has “commented” any words after it. This means that the Arduino IDE compiler will ignore this code when loading it into the Arduino Uno. Commenting code is a super useful way to leave notes for yourself or other developers when planning and explaining parts of your code. 

Next, add a few lines using enter, and then type // Display – it should look like this:

 

 

This is a great start, you now have a clear template thanks to planning via pseudocode. 

 

End Of Part 2

In part 3, we will expand upon our template with real code, to automate the countdown of the timer.

See you next time and thanks for reading!

 

READ PART 3 HERE

Build Your Own Escape Game Artefacts! Part 1

Image

Have you ever wanted to build your own escape game artefacts using low voltage electronics? Look no further! In the upcoming months, look out for a short series of articles on how you can approach creating small, but effective artefacts for your own game designs.

Introduction

Why am I known as RussBuilds? Because I like to build things; particularly electronics, that lead to creating an escape game artefact; an object that can be held or handled, to solve and is usually hiding something like a key or a secret message to progress further.

I made 4 games over the course of the lockdown period, each involving multiple escape game artefacts, and Mairi right here at The Escape Roomer, reviewed 3 of them. (ENDGAME, AIRLOCK and CITIZEN if you are interested).

I discontinued these games in June 2021, however I would love to pass on some skills and insight into anyone who is considering making their own physical escape games, but doesn’t know where to start.

 

 

Part 1: Fundamental Equipment

What do I mean by fundamental equipment?

Later on in the series, I’ll be showing you how to build an escape game artefact. Fundamental equipment is the absolute basics you need for all artefact building; without these components you won’t get very far!

So without further a-do, let’s begin.

 

Microcontroller

A microcontroller is the brain of any artefact. It receives power and transmits signals to components, telling them to perform an action eg: unlock an electronic lock, show a message to the player etc. There are many microcontrollers out there, but the one I shall reference in this series, is the Arduino Uno.

 

 

Why this one? It’s the most popular one in the world, has tons of technical support for it and most importantly, is an open-source design. This means that the design of the Arduino Uno can be replicated by anyone. The Arduino Uno retails at around £20 per unit and this can get pricey, if you want to build multiple artefacts.

However! There are plenty of open-source copies out there that are up to a fifth of the price, making a project like this, much more accessible.

 

 

Also don’t forget to buy an Arduino USB connector, sometimes they are included but always check; you need one to connect it to a computer!

 

Power Adapter

You need a power adapter to power the microcontroller. The Arduino Uno outputs a maximum of 5 volts (V) to anything connected to it that requires power eg: an electronic lock or an LCD display. I personally use, power adapters that are rated between 5V and 9V and have an ampere (A) rating between 500mA and 1A. Combining these two figures (V x A) creates power, also known as Watts (W). If the power is too low, the microcontroller won’t be able power output components. If the power is too high however, you risk overheating/hot-to-touch components and very possibly; even frying the electronics inside…or worse causing an injury to yourself or others.

I do stress, that my usage of power adapters is merely what I personally use. I strongly suggest that you do your own research on what power adapter(s) you should use. Checking the Arduino Forums, may be a good start of information.

 

Laptop & IDE

For Arduino microcontrollers, you will need a laptop (or desktop computer) to connect and tell what you want it to do. The one I use for these projects, is a 10 year-old Samsung with 4GB RAM and an Intel dual core i5 processor. In other words, not fancy, in the slightest. If you have an old laptop lying around and you can power it up, give it a go, you may have given it a lease of new life!

Secondly, you will need to download the Arduino IDE (Integrated Development Environment) – this will be your workspace where you will tell the microcontroller what you want it to do, using C++ coding language. (Before you start panicking, yes there will be an entry in this series on introductory coding).

 

 

The Arduino IDE has regular updates and is supported on PC, iOS and Linux systems.

 

Dupont Connectors

Dupont connectors, connect the microcontroller to any outputs. The great thing about dupont connectors? They are cheap and easy to use. There are 3 types of dupont connectors that you will need;

  • Male to Male
  • Female to Female
  • Male to Female

 

Depending on what is connected to the microcontroller, it is best to have all 3 types handy, for all eventualities. Get assorted colours too eg: some red, some black etc; it’ll be easier to troubleshoot hardware errors later.

 

Connector Blocks

Connector blocks are plastic or rubber covered and are ideal for either extending or joining several dupont connectors together. If you are using radio frequency tags for example, connector blocks are vital, as radio frequency modules have multiple inputs that do different things. Connector blocks are usually bought in rows of 12 and can be easily cut down if you only need a few at a time.

You’ll also need a small philips or flat blade screwdriver to adjust the tightness of the blocks when the connectors are placed in.

 

 

End Of Part 1

Those are your fundamentals that you need before you can start creating your escape game artefacts. In part 2 we will look at the Arduino Uno in detail, alongside the IDE and some common coding syntax, you will use for a countdown timer artefact.

Read Part 2 Here

Thanks for reading!