Amanda
Published © GPL3+

Mini Escape Room

A mini escape room featuring micro-controllers and an electromagnet!

IntermediateFull instructions provided5 hours7,014
Mini Escape Room

Things used in this project

Hardware components

ELEGOO UNO R3 Board ATmega328P ATMEGA16U2 with USB Cable
ELEGOO UNO R3 Board ATmega328P ATMEGA16U2 with USB Cable
×1
Arduino UNO
Arduino UNO
×1
Linear Solenoid, 12.3 VDC
Linear Solenoid, 12.3 VDC
×1
Hook Up Wire Kit, 22 AWG
Hook Up Wire Kit, 22 AWG
×1
SparkFun 7-Segment Serial Display - Red
SparkFun 7-Segment Serial Display - Red
×1
Elegoo 4x4 Matrix Keypad
×1
Acrylic
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Cura
Google SketchUp

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Laser cutter (generic)
Laser cutter (generic)
Not 100% needed if you do not create a protective case for the room.
Wire Stripper & Cutter, 26-16 AWG / 0.4-1.29mm Capacity Wires
Wire Stripper & Cutter, 26-16 AWG / 0.4-1.29mm Capacity Wires
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

Linear Actuator for Servo

Linear actuator to move the electromagnet down to reveal the secret code. Credit to Geekmakes - Thingiverse

Schematics

Elegoo Fritzing Bin

Credit to Marcinwisniowski Full bin of the elegoo arduino starter kits used to create the fritz schematic

Code

Keypad Code

Arduino
Code to engage the servo on the linear actuator and activate the magnet relay. Note that only the correct input will activate the servo and turn on the magnet.
// Amanda Grutza
// Keypad Magnetic Reveal


#include <VarSpeedServo.h>
// Name we give servo
VarSpeedServo magnet_servo;
// servo on pin 2
int servo_pin = 2;
// up position
int up = 0;
// down position
int down = 55;

// Keypad
#include <Keypad.h>
#include <Password.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {5, 6, 7, 8};
byte colPins[COLS] = {9, 10, 11, 12};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

// set passcode
Password passcode = Password( "6273" );

// Miscellaneous Stuff
// led on pin 13
int led = 13;
// magnet relay on pin 4
int relay = 4;

int red = A5;
int green = A4;

void setup() {

  // active serial communication
  Serial.begin(9600);

  pinMode(red, OUTPUT);
  digitalWrite(red, LOW);
  pinMode(green, OUTPUT);
  digitalWrite(green, LOW);

  // set servo pin 5 (from above)
  magnet_servo.attach(servo_pin);
  // set servo position to start
  // position, speed 0 to 255, true = now or false = wait for next
  magnet_servo.write(up, 150, true);

  // tell arduino this pin goes out
  pinMode(led, OUTPUT);
  // set led off
  // LOW = off HIGH = on
  digitalWrite(led, LOW);

  // ditto buddy
  pinMode(relay, OUTPUT);
  // set magnet off
  digitalWrite(relay, LOW);

  // Keypad Listener
  keypad.addEventListener(keypadEvent);

  // Change This!!!
  Serial.println("Enter the code now! ..or else!");

}

void loop() {
  keypad.getKey();
  delay(5);
}

void keypadEvent(KeypadEvent eKey) {
  switch (keypad.getState()) {
    case PRESSED:
      Serial.println(eKey);
      button();
      switch (eKey) {
        case '#': check_passcode(); break;
        case '*': passcode.reset(); break;
        default: passcode.append(eKey);
      }
  }
}

void check_passcode() {
  if (passcode.evaluate()) {
    reveal();
  } else {
    digitalWrite(red, HIGH);
    delay(1000);
    digitalWrite(red, LOW);
  }
}

void reveal() {
  // send servo down
  magnet_servo.write(down, 70, true);
  // wait for it to get down, ya'll
  delay(2000);
  // turn on magnet
  digitalWrite(relay, HIGH);
  // give it a second to power on
  delay(500);
  // raise servo
  magnet_servo.write(up, 70, true);
  // turn on led
  digitalWrite(led, HIGH);
  // wait 6 seconds
  delay(6000);
    // turn off magnet
  digitalWrite(relay, LOW);
  //lower servo
  magnet_servo.write(down, 70, true);
  delay(1000);
  // turn off led
  digitalWrite(led, LOW);
  // raise servo to middle
  magnet_servo.write(up, 70, true);
  delay(1000);
  passcode.reset();
}

void button() {
  digitalWrite(green, HIGH);
  delay(250);
  digitalWrite(green, LOW);
}

Time Bomb Code

Arduino
Code for the secret numbers on the 4 digit display. Easily swapped out for different numbers.
#include <TM1637Display.h>

const int CLK = 3; //Set the CLK pin connection to the display
const int DIO = 2; //Set the DIO pin connection to the display


int NumStep = 0;  //Variable to interate

TM1637Display display(CLK, DIO);  //set up the 4-Digit Display.

void setup()
{
  display.setBrightness(0x0a);  //set the diplay to maximum brightness
}


void loop()
{
 
  {
    display.showNumberDec(1470); //Display the Variable value;
    
  }
}

Credits

Amanda
2 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.