Michael Guerero
Published © GPL3+

Secret Batman Bust Switch

Unlock an inconspicuous chest from across the room with a secret switch!

BeginnerShowcase (no instructions)20,375
Secret Batman Bust Switch

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×2
Nordic Semiconductor NRF24L01 Radio Transciever
×2
Servo Motor
×1
Press Button Switch with LED
×1
12V Solenoid
×1
5V Relay Module
×1
Capacitor 100 µF
Capacitor 100 µF
×2
4xAA battery holder
4xAA battery holder
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1

Software apps and online services

Fusion 360
Autodesk Fusion 360

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Custom parts and enclosures

Bust_Statue

Bust_Pedestal

Bust_Pedestal_Top

Gear Mechanism

Servo Mount

Schematics

Bust Switch Electronics

Box Electronics

Bust

Box

Code

Button and Box Code

Arduino
The first section is for the arduino in the bust. The second section is for the arduino in the box.
/* Secret Bust Button
 * Bust
 */
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";

const int buttonPin = 9;
bool buttonState;
//bool prevButtonState = 0;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();

  pinMode(buttonPin, INPUT);
}

void loop() {
  buttonState = digitalRead(buttonPin);
  Serial.println(buttonState);

  radio.write(&buttonState, sizeof(buttonState));
  }
  
  
  
  
  /* Secret Bust Switch Project
 * Box Code
*/

// Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>

// Create Objects
RF24 radio(7, 8); // CE, CSN
Servo servo;

// Declare Variables
const byte address[6] = "00001";
bool buttonState;
const int solenoidPin = 4 ;
const int servoPin = 3;
bool lidOpenState = false;
int pos;
int prevButtonState;

void setup() {
  Serial.begin(9600);                       // Start Serial Monitor
  radio.begin();                            
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();                   // Start Listening for radio transmission
  pinMode(solenoidPin, OUTPUT);
  digitalWrite(solenoidPin, HIGH);          // Release (Lock) Solenoid
  servo.attach(servoPin);                   
  servo.write(5);                           // Home Servo to 0 Deg (Box Closed Position)
  delay(1000);                              // Wait one second
  servo.detach();                           
}

void loop() {
if (radio.available()){
  radio.read(&buttonState, sizeof(buttonState));
  prevButtonState = buttonState;
  for (int n=0; n=5; n++){
    radio.read(&buttonState, sizeof(buttonState));
    delay(50);
    if (prevButtonState != buttonState){
      n = 0;
    }
  Serial.print("Button State:    "); Serial.println(buttonState);
  Serial.print("Lid Open State:    "); Serial.println(lidOpenState);
  if (buttonState == true && lidOpenState == false){          // If bust switch is pressed and lid is closed...
    openLid();                                                // Open lid seqence...
    lidOpenState = true;                                      // Lid is now open
  }
  if (buttonState == false && lidOpenState == true){          // If bust switch is unpressed and lid is open...
    closeLid();                                               // Close lid sequence...
    lidOpenState = false;                                     // Lid is now closed
  }
}
//delay(100);
}
}
/*
------------------------------------------------------------------------------------------------------------------------------------
                                                    Open lid sequence
------------------------------------------------------------------------------------------------------------------------------------
*/ 
void openLid(){                                               
    Serial.println("Opening");
    digitalWrite(solenoidPin, LOW);              // Engage(unlock) Solenoid
    servo.attach(servoPin);                                   
    delay(500);
    servo.write(180);
    delay(1200);
    servo.detach();
    digitalWrite(solenoidPin, HIGH);            // Solenoid is in released (locked) position
}

/*
------------------------------------------------------------------------------------------------------------------------------------
                                                    Close lid sequence
------------------------------------------------------------------------------------------------------------------------------------
*/ 
void closeLid(){                                              
    Serial.println("Closing");
    digitalWrite(solenoidPin, LOW);                             // Engage (unlock) Solenoid
    servo.attach(servoPin);
    delay(500);
    servo.write(5);
    delay(1200);
    servo.detach();
    digitalWrite(solenoidPin, HIGH);                          // Solenoid is in released (locked) position 
}

Credits

Michael Guerero

Michael Guerero

3 projects • 43 followers
Earned my BS in Mechanical Engineering from Cal Poly Pomona in 2018. Currently working for the California Air Resources Board.

Comments