Introduction: Arduino Nano Secret Safe Combination Box Amp Style
Hi everyone, in this instructable i´ll show you how yo make a cool loking safe box with an Arduino nano disguised as a guitar amplifier with zero power consumption when closed, cool right?
I don´t have experience on programing and i´m just starting to learn with arduino so this was a challenge for me, i saw the instructable made by HavocRC https://www.instructables.com/id/Arduino-Combinatio...
and i thought it would be cool to make some sort of safe box, so i took his idea and the code for using the potentiometers for entering the combination and made my own version.
So i hope you like my instructable :)
Step 1: Materials
Materials:
-1 Wood sheet, nails and glue to make the box
-1 Arduino Nano
-1 Micro servo
-1 Sliding latch
-4 10k potentiometers
-2 Led´s
-4 Resistors (220ohm, 1k ohm, 10k ohm, 10k ohm)
-1 push button
-1 End stop switch
-1 Piezo
-1 light outlet
-1 male plug with wire
-1 red Rocker switch
-1 5v usb phone charger
-1 piece of thin wood for the logo 15cm x 5cm
-2 hinges
-1 Transparecy
-Fabric for lining the box, i used some cheap synthetic leather
Step 2: Design, Cut and Assemble the Box
I first made a sketch of the box with Google Sketch up 8 to see how would it look finished and have the right proportions. My box mesures 50 centimeters by 60 cm and 30 cm deep.
I am not going to go into much details on the construction of the box, i´m sure you can find a specific instructable for that, like this one:
Step 3: The Circuit
first thing i did was to assemble the circuit on a proto board, i know it looks a bit messy but that was just for testing it.
After i was sure everything worked i made a shield for the arduino uno.
Important. Make sure to solder the wires in the correct pins of the shield.
I connected a power outlet inside the box to power the arduino using a 5v usb cell charger, it allows to save energy when not in use because, the red rocker switch, so you only turn on the power when you want to open the box and when you finish saving your stuff just power off and the arduino won´t consume any power.
Step 4: Making the Front Cover and Faceplate
Once you solder the components for the shield, drill holes for the potentiometers, the leds and the switch.
Then i measured a 5 cm line from the top and spray painted gold.
I couldn´t find the grill cloth used for amps in my city and ordering online was too expensive so i used some black fabric instead.
once the potentiometers are fixed on their positions i loaded this sketch and marked on the wood with a pencil a line for every number.
<p>int redLED = 3;<br>int greenLED = 13;</p><p>void setup() { Serial.begin(9600); pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); }</p><p>void loop()</p><p>{ int analog1 = analogRead(A0); int pot1 = analog1 * (10.0 / 1023.0); int analog2 = analogRead(A1); int pot2 = analog2 * (10.0 / 1023.0); int analog3 = analogRead(A2); int pot3 = analog3 * (10.0 / 1023.0); int analog4 = analogRead(A3); int pot4 = analog4 * (10.0 / 1023.0);</p><p>if (pot1 == 1 && pot2 == 2 && //here the password is 1234, just change it to your own password pot3 == 3 && pot4 == 4) { digitalWrite(greenLED, HIGH); digitalWrite(redLED, LOW); }</p><p>else { digitalWrite(greenLED, LOW); digitalWrite(redLED, HIGH); }</p><p>Serial.print(pot1); Serial.print(pot2); Serial.print(pot3); Serial.print(pot4); Serial.println();</p><p>}</p>
I am not very good with editing software so i used microsoft word, i measured the space between every line so it matched the number showed on the arduino serial monitor and the number printed on the faceplate, it took some time because i measured the milimeters between every line and adjusting it on Word.
I printed it in normal paper, cut it and pu it over the potentiometers to test it.
Then i printed it on a transparency and glued in place.
Step 5: Locking Sistem
To keep the box locked i used a latch, a micro servo, a piece of wood and some bamboo sticks.
first place the latch on the side and mark the piece of wood.
to move the latch i made this piece with some bamboo sticks i had laying around, glued it and carve it with the dremel. this could have been easier with a 3D printer but sadly i don´t have access to one :(
then i glued the micro servo under the latch and move it to 0° using this sketch:
#include<Servo.h> <p>Servo myservo;</p><p>void setup() { myservo.attach(8); }</p><p>void loop() { Serial.begin(9600);</p><p>myservo.write(0); Serial.println("0°"); delay (6000);</p><p>myservo.write(18); Serial.println("18°"); delay (1000); }</p>
i found that 0° was at the top of the servo, (see the image), then i inserted the top of the lever to the servo to the closed position. you have to play around a little to find out which position is open, for me it was 14° you may have a diferent number depending on the size and position of the latch.
,
Step 6: The Code
This was the most dificult part for me because i am a beginner using arduino so i didn´t know at first how to program it, i used counters to move the servo when the potentiometers are in the correct position and the counters have a specific number of button pushes.
the code mainly works like this:
A red led will fade on and off to show that the arduino is up and running.
When you press the front button once, the counter adds 1, if you press the button a second time the counter adds 1 and only when the counter is equal to 2 and the potentiometers are in the correct position, the blue led will blink, the piezo bips 3 times and the servo will move to allow to open the box.
the counter restarts to 0 if you press the button 5 times and the potentiometers are not in the correct potition.
there is a hidden reed switch with a counter to open the box with a magnet in case you forget the password.
once the door is open the blue led will keep on, and when you close the door the piezo will tone twice, the red light will blink twice as well and the servo will move to closed position securing the box.
i added a reed switch so if i forget the combination i can open it with a magnet placing it in the right place.
so this is my code, im sure there is a more efficient way to do it, so if you know one, please let me know.
#include<Servo.h> <p>const int RedLED = 3;<br>const int BlueLED = 13;</p><p>const int Reed = 12; //Reed Switch on pin 12 const int button = 11; //pushbutton on pin 11 const int buttondoor = 7; //limit switch on pin 7 for closing box door</p><p>int buttonState = 0; //state for the front switch int buttonStatedoor = 0; // current state of the end switch int ReedState = 0;</p><p>int buttonCounter = 0; // counter for the number of button presses int ReedCounter = 0; // counter for the reed Switch int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by Servo myservo;</p><p>void setup() {</p><p> pinMode(RedLED, OUTPUT); // define LED´s as outputs pinMode(BlueLED, OUTPUT); pinMode(button, INPUT); //define front button as input pinMode(Reed, INPUT); //define reed switch as input pinMode(buttondoor, INPUT); //define limit switch for door as input myservo.attach(6); }</p><p>void loop(){</p><p>buttonStatedoor = digitalRead(buttondoor); //read the state of the end switch on the door</p><p>if (buttonStatedoor ==LOW){ //move the servo if the door is closed to keep it locked myservo.write(0); }</p><p>ReedState = digitalRead(Reed); //read the state of the reed switch delay (20); buttonState = digitalRead(button); // read button delay (20);</p><p>if (buttonState == HIGH && buttonCounter ==0){ //if button is pressed for the fist time delay(100); tone(8,360,300); buttonCounter++; //add 1 to counter }</p><p>else if (buttonState == HIGH && buttonCounter ==1){ //if button is pressed for the second time delay(200); buttonCounter++;} </p><p> else if (buttonState == HIGH){ //keep counting the button presses delay(100); buttonCounter++; }</p><p> if (ReedState == HIGH) { //counter for the hidden reed switch delay(300); ReedCounter++;}</p><p>if (buttonCounter <=2){ // the LED will fade on and of while the box is closed analogWrite(RedLED, brightness); // set the brightness of red led: brightness = brightness + fadeAmount; // change the brightness for next time through the loop: if (brightness == 0 || brightness == 255) { // reverse the direction of the fading at the ends of the fade: fadeAmount = -fadeAmount ; // wait for 30 milliseconds to see the dimming effect delay(30); } }</p><p>int analog1 = analogRead(A0); //read the value of the 4 potentiometers connected from int pot1 = analog1 * (10.0 / 1023.0); // A0 to A3 and scale them to 10 int analog2 = analogRead(A1); int pot2 = analog2 * (10.0 / 1023.0); int analog3 = analogRead(A2); int pot3 = analog3 * (10.0 / 1023.0); int analog4 = analogRead(A3); int pot4 = analog4 * (10.0 / 1023.0); </p><p>if (pot1 == 1 && pot2 == 2 && //Here is the "password" to open the box with the potentiometers pot3 == 3 && pot4 == 4 && buttonCounter == 2) { digitalWrite(RedLED, LOW); //turn off red LED tone(8,4000,100); //piezo on pin 8 digitalWrite(BlueLED, HIGH); delay(100); digitalWrite(BlueLED, LOW); delay(100); tone(8,2000,100); digitalWrite(BlueLED, HIGH); delay(100); digitalWrite(BlueLED, LOW); delay(100); tone(8,2000,100); digitalWrite(BlueLED, HIGH); //keep the blue LED on while the door is open delay(100); myservo.write(14); //move servo 14° to open box buttonCounter++; delay(3000); //wait 3 seconds to open the cover, if not, the servo moves } //again to closed position</p><p>buttonStatedoor = digitalRead(buttondoor); delay (20);</p><p> if (buttonStatedoor ==LOW && buttonCounter==3){ //move the servo if the door is closed to keep it locked myservo.write(0); digitalWrite(BlueLED, LOW); buttonCounter=0; //reset counter }</p><p> while (buttonStatedoor ==HIGH && buttonCounter==3){</p><p> myservo.write(14); buttonStatedoor = digitalRead(buttondoor); delay (20);</p><p>if (buttonCounter==3 && buttonStatedoor ==LOW) //when the door is closed the servo will go back to closed position {</p><p> digitalWrite(RedLED, HIGH); delay(200); tone(8,1000,300); digitalWrite(RedLED, LOW); delay(200);</p><p> digitalWrite(RedLED, HIGH); delay(200); tone(8,1000,300); digitalWrite(RedLED, LOW); delay(200); myservo.write(0); //move servo to close digitalWrite(BlueLED, LOW); delay (3000); buttonCounter=0; //reset counter delay (500); } } if (buttonCounter ==5) //reset counters when the button is pressed 5 times { digitalWrite(BlueLED, HIGH); delay(200); tone(8,300,150); digitalWrite(BlueLED, LOW); delay(200); buttonCounter=0; ReedCounter = 0; } if (ReedCounter == 5){ //if reed counter is equal to 20 move servo to open box myservo.write(14); //in case you forgot the password buttonCounter = 0; delay (2000); ReedCounter = 0; } }</p>
Attachments
Step 7: Making the Logo
The logo gives the box a more realistic look of a guitar amp, i used my last name, you can use yours, or if you want it to look more real use the Marshall logo, just look for it on google, and print it the size you want, my logo measures 15cm by 5cm. or if you are lucky enough and have acces to a 3D printer you can use it and save some work.
when you have the logo printed, paste it on a thin piece of wood, i used a broken bamboo kitchen cutting board.
Carefully remove the excess wood. mine broke a few times, just glued it again an let it dry.
To remove the wood from the inside of letters i drilled some holes and remove it with a flat screwdriver.
Then use the Dremmel to remove the paper and sand the logo until you have a smooth finish.
Finally spray paint the logo and glued it in place.