Build Your Own Escape Game Artefacts! Part 2

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

Build Your Own Escape Game Artefacts

 

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

Author

  • RussBuilds is an independent escape game designer. Here, he is writing on video games and escape rooms in the middle of the UK.

Related post

0 Comment

Leave a Comment

%d bloggers like this: