Magnetically-activated escape room prop controller (Patreon)
Downloads
Content
Hi folks! This month's tutorial is about a very common type of sensor used in escape room puzzles - magnetic sensors - i.e. Hall sensors and reed switches.
Whether it's returning a dragon's egg to a nest, placing a missing book back in the correct position on a shelf, or moving a chesspiece to a certain square on a chessboard, a simple magnet embedded in almost any portable prop component can be detected and trigger a response - activating a relay, opening a maglock, or firing a smoke machine. Like many other ER sensors, if done well, this simple technology can create "magic" as far as the player is concerned!
While it's not difficult to find code examples of how to use a magnetic sensor with an Arduino, I couldn't find anything that compared different properties of sensors, or answered important questions like "how close does a magnet have to be detected?" or "will this work the same for both the North and South pole of a magnet?". So that's what I'll try to do in this tutorial: by showing you first how to understand their datasheets, and then giving a practical demonstration of some common readily-available magnetic sensors - the Honeywell SS49E, Allegro A3144, A1324, and A1389 - giving a live demonstration of their output and sensitivity to different magnets, and particularly focussing on which ones are most suitable to use in an escape room context.
I'll then show you how to write the Arduino code for an all-purpose magnetic prop controller which automatically calibrates to its environment on startup, has adjustable sensitivity, and fires separate triggers to respond to either a North pole or South pole of a magnet. This makes it possible to use not only for object detection, but also basic object identification/differentiation if a pattern of magnets of different polarities are presented to an array of readers (which could be used as an alternative to RFID, say).
I hope you find this a relatively comprehensive guide, providing you with all the details you require to create your own magnetically-activated puzzle props. But, as always, if there are remaining questions which you have, or any comments or suggestions I'd love to hear them!
I'll put the Arduino code download, the STL of the 3d-printed Hall sensor mount, and wiring diagram etc. in a separate post for Patreons shortly.
UPDATE
I've also now attached a modified version of the code provided by Todd Child designed to accommodate 5 sensors - thanks Todd!
Timings
00:00 - 01:23 Introduction
01:24 - 04:20 Selecting a magnet
04:21 - 04:45 Selecting a magnetic sensor
04:46 - 05:47 -Reed switches
05:48 - 13:42 -Hall sensors (SS49E, A1324, A1389, A3144)
13:43 - 14:32 Practical sensor comparison
14:33 - 18:49 -Wiring
18:50 - 19:51 -Arduino code
19:52 - 24:15 -Live demo
24:16 - 25:55 -Analysis of findings
25:56 - 29:27 Creating a magnetically-activated ER prop controller
29:28 - 41:11 -Arduino code
41:12 - 43:12 -Live demo
43:13 - 44:08 Wrapup