How To Make A Lego Safe Mini
Introduction: Lego Caput Safe
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of S Florida (world wide web.makecourse.com). This oroject was done by Kaitlin Bellerose, a student in the course.
The idea behind the condom is that a servo spins into place in an aperture, either opening or closing the Lego head safe. The Arduino code controls the functionality of the safe and password entry/storage.
The following materials and tools are needed for successful cosmos of the project:
one) Arduino Uno
2) 4x4 matrix keypad
3) Jumper wires and resistors
iv) 9V battery and connector to Arduino Uno
5) Blackness box or like secure box
6) LCD screen
7) Mini servo and stand up
8) Mini breadboard
9) Square oak dowel
10) Black acrylic paint
11) White acrylic paint
12) Dremel and pads
xiii) Super gum
14) Philips head screwdriver with small caput
15) 3D printer to make head
16) Fine paintbrush
17) Fine-grain and coarse-grain sandpaper
Footstep 1: Circuit Schematic
The circuit is pinned out equally follows:
The LCD is hooked to pins AREF and GND.
The servo is fastened to pin 11.
The 4x4 matrix keypad is tied to pins 8, 7, half-dozen, v, and iv, 3, 2, 10. I have a expressionless pivot at 9, and then the wiring is a scrap jumbled. Wire yours the style it makes sense to you and what pins y'all have available. Keep in listen that pins 1 and 0 are reserved for TX and RX.
Stride 2: 3D Printed Parts
The dimensions were scaled from the case found on the Instructables site of a Lego figurine: https://www.instructables.com/id/LEGO-Man-Costume/s...
The head was scaled in millimeters to approximately 4 times the size of the example. As for the actual press of the part, I did not have much of a decision with regard to the orientation of the particular prior to print. I received the caput parts from the university visualization lab.
Once you lot print out the required part, super mucilage the pieces together. I initially tried to print out the heads that would fit snugly within each other, but I could non get the tolerances correct to fit.
The opening at the bottoms of the Lego head is rectangular, allowing for the ellipsoidal horn (wings) of the servo. The wing is brusque on the vertical axis and longer on the horizontal. You may need to arrange the width of the rectangular pigsty (or trim the servo horn as a last resort).
The MAKE projection for our class required that nosotros utilise a DC-47 enclosure instance. The box tin can be found hither: http://world wide web.polycase.com/dc-47p.
Step three: Physical Construction
Afterward you finish wiring the components outside of the enclosure, you will realize that choices accept to be made to become the wiring to fit. Simply before you lot e'er put the instance together, you have to marking and cut the apertures needed to have the LCD fit into the side of the box and the servo arm fit through the top of the box.
When cutting with the Dremel, please take great intendance to have proper ventilation because the fumes that come off the heated-up plastic box are noxious. A safety route would be to redesign and reprint the box.
The stand I used was a castaway item provided past a classmate that happened to serve its purpose. For your purposes, find a stand or stack of stable items (like connected Lego blocks) to identify the servo on.
The mess of wires is hard to control. You will need to attach the matrix pad to the Arduino via a female-to-female connector. The servo will also need to be attached to its stand so it does not autumn over due to the detail beingness knocked or the twisting wires settling, causing it to fall. Super glue is a skillful selection, though, again, lookout for the fumes.
The Lego head needs to have the support material removed and the roughness sanded off. I cannot recommend any particular kind or grain of sandpaper because I just used leftover fine and coarse grain sandpaper I had left over when I painted my auto. As with nigh things, test sand in a spot that will non be visible prior to completely sanding the whole area completely.
For the cosmetic portion of the project, reference the expect of a Lego head before proceeding. I recommend that yous practice your strokes on a paper plate or any older iterations prior to committing the pigment to the final product.
The Lego head equally it is designed tin can easily be twisted and picked off the servo regardless of whether the servo is in closed or locked position. To stop this ability to defeat this lock by twisting the head, I glued a pocket-sized piece of foursquare dowel to the neck of the caput and glue ii corresponding pieces on the box lid that would straddle the dowel to prevent the caput from being twisted. I painted the dowel pieces black to match the box. The dowel was obtained from Home Depot.
The matrix keypad has agglutinative on the back of it, merely I elected to apply the matrix keypad with super glue. To ensure that the keypad stays in place, put something heavy on top that would not necessarily gear up off the keypad itself (like the h2o glass I used).
In one case washed, completely spike the screws of the box. Please keep in mind that the life of the safe is non very long because the 9V bombardment lasts near four hours of continuous use To keep information technology constantly powered, you will take to use the USB cable and cut a corresponding hole in the box for it. For the purposes of the demo, I used the 9V to have an independent arrangement to present.
Stride 4: Code
The code used existing libraries for the LCD, Servo, and Keypad. I created my own code with regard to the password system and overall functionality. The code provides three options for the condom: open up, close, and fix password. In order to change the password, the user has to know the existing password. The lawmaking is fully commented for the ease of a person new to programming.
The following and attached is my lawmaking. Please experience free to employ it!
/***************************************************************************************************************************
Title: Lego Head Safety
Author: Kaitlin Bellerose
Date: 11/01/2014
Updated: 12/03/2014
Purpose: This sketch provides the control system for the Lego Caput safe.
This sketch borrows from multiple sources. The original sources will be cited here in the championship block when full general approaches were followed.
i) Keypad.h library written by Mark Stanley and Alexander Brevig (mstanley@technologist.com, alexanderbrevig@gmail.com)
two) At that place is a password.h library available on Instructables and similar sites. I did not care for the implementation, and so I created my own. ****************************************************************************************************************************/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27,16,2); // Instantiate a 16x2 I2C LCD display with address 0x27
Servo myServo; // Instantiate a servo
int pos; // Declare variable to hold servo position value (NOTE: "position is a reserved discussion)
int servoSpeed; // Declare variable to concur servo speed value (Annotation: "speed" is a reserved word) char password[3]; // Array that holds master password. Prepare to length yous would similar. I chose 3 for ease of demo char entry[3]; // Assortment that holds the user-entered countersign attempt
boolean isAlreadyOpen; // Flag that tracks whether safe is already open
boolean isAlreadyClosed; // Flag that tracks whether safe is already closed
const byte ROWS = 4; // Four rows in 4x4 keypad matrix
const byte COLS = 4; // Four columns in 4x4 keypad matrix
char keys[ROWS][COLS] = { // Maps the keypad values {'ane','ii','iii', 'A'}, {'iv','five','vi', 'B'}, {'7','8','9', 'C'}, {'*','0','#', 'D'} };
byte rowPins[ROWS] = {8, 7, 6, 5}; // Connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2, 10}; // Connect to the column pinouts of the keypad
// Apply 1 or more appropriate pin for what I have labeled every bit "10"
// My Arduino has many expressionless ports I take to navigate around
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); // Instantiates a keypad with the values passed.
/********************Ready-up Function*********************/
void setup(){ Serial.begin(9600); // Set up series to 9600 baud
myServo.attach(11); // Set servo to pin 11
isAlreadyOpen = 0; // Sets open flag to false
isAlreadyClosed = i; // Sets closed flag to truthful
pos = 90; // Sets value for servo arm position at xc degrees
servoSpeed = 3; // Sets servo speed to 3 degrees per second
myServo.write(pos); // Sets servo arm to xc degrees
password[0] = 'one'; // Be sure to put initial value in single quotes due to its char nature
password[i] = 'two'; // Second value in password array
password[two] = '3'; // Concluding value in password. The password will default to "123" when // power is lost.
keypad.setDebounceTime(250); // Sets the push debounce time for the keypad
lcd.init(); // Initialize the LCD
lcd.backlight(); // Set the display to be backlit
lcd.impress("Welcome Home!"); // Print welcome message to LCD
delay(1000); // Have message display for one thousand milseconds
lcd.clear(); // Articulate the display
lcd.print("i) Open 2) Shut"); // Impress carte options
lcd.setCursor(0,1); // Move cursor to second line
lcd.print("3) Ready Code"); // Print second part of menu options
delay(3000); // Delay
}
/***************Main Loop*****************/
void loop(){
entry[0] = NO_KEY; // Reset the entry array with each loop or else
entry[1] = NO_KEY; // yous'll get "false" entries from existing values
entry[2] = NO_KEY; // Set the final keypad to NO_KEY (similar to setting //
value to NULL in C++)
char central = keypad.getKey(); // Go the kickoff key press with regard to carte du jour.
if (fundamental == '1'){ // Initiates logic if "Open up safe" option is selected
if(isAlreadyOpen == 1) // Checks to meet if the rubber is already open. No betoken in opening something already open
{
lcd.clear(); // Articulate LCD
lcd.print("Safe is already"); // Prints message
lcd.setCursor(0,1); // Move cursor to 2d line
lcd.print("open."); // Print 2d part of carte options
delay(2000); // Delay 2000 miliseconds }
else // If the safety is not already open, the post-obit code engages {
lcd.clear(); // Clear the LCD
lcd.print ("Enter 1st cardinal:"); // Bulletin to solicit the get-go key press
lcd.setCursor(0,one); // Moves cursor to 2nd line
while (entry[0] == NO_KEY) // The loop runs until a valid key press is made
`{
entry[0] = keypad.getKey(); // Stores the outset value of the user-entered attempt at countersign
}
lcd.print(entry[0]); // Prints value for display on LCD. Use for debugging and ease of use. delay(1000); // Delays for yard miliseconds
lcd.clear(); // Clears LCD
lcd.print("Enter 2nd primal:"); // Enter the second key press
lcd.setCursor(0,one); // Move curosr
while (entry[i] == NO_KEY) // Some other loop that will run endlessly unless a valid keypress is fabricated
{ entry[one] = keypad.getKey(); // Stores the second value of the user-entered attempt at countersign }
lcd.impress(entry[1]); // Prints value for brandish on LCD. Use for debugging and ease of employ. delay(1000); // Delay for 1000 miliseconds
lcd.clear(); // Clear LCD
lcd.print("Enter 3rd key:"); // Solicit third key press
lcd.setCursor(0,1); // Moved the cursor
while (entry[2] == NO_KEY) // Once again, a while loop to continuously poll unti a valid central press is made. {
entry[2] = keypad.getKey(); // Gets the final key press
}
lcd.print(entry[2]); // Prints value for brandish on LCD. Use for debugging and ease of apply. filibuster(thousand); // Delay for g miliseconds
lcd.articulate(); // Clear LCD
if ((entry[0] == password[0]) && entry[one] == password[1] && entry[two] == password[2]) // If what the user entered matches the stored countersign, this loop executes
{
isAlreadyOpen = one; // Prepare isAlreadyOpen flag to true/high
isAlreadyClosed = 0; // Prepare isAlreadyClosed flag to false/low
pos = 180; // Set position to 180 degrees
myServo.write(pos); // Gear up the servo to 180 degrees
lcd.articulate(); // Clear LCD in anticipation of bulletin
lcd.print("Condom is open."); // Message that the safe is open
delay(2000); // Delay of 2000 miliseconds }
else // If the wrong code was entered, this executes
{
lcd.clear(); // Clear LCD
lcd.print("Invalid code."); // Invalid code message
delay(thou); // Filibuster thousand miliseconds
lcd.clear(); // Articulate LCD } }
mainLCDMenu(); // Regardless of whether countersign entry was successful, this kicks back to the main menu functions }
else if (key == '2')
{ // Initiates if "Close safe" is selected
if(isAlreadyClosed == i) // If the head is already closed, why close it once again?
{
lcd.clear(); // Articulate LCD
lcd.print("Safe is already"); // Begin message that the safe is already closed lcd.setCursor(0,1); // Move cursor to second line
lcd.print("airtight."); // Finish message
filibuster(2000); // Delay for 2000 miliseconds delay }
else // If the prophylactic is not already closed, this executes
{ isAlreadyOpen = 0; // Sets isAlreadyOpen flag to simulated/low
isAlreadyClosed = i; // Sets isAlreadyClosed flag to truthful/high
pos = 90; // Sets pos to 90 degrees
myServo.write(pos); // Sets servo to xc degrees
lcd.clear(); // Clears LCD
lcd.print("Safe is closed."); // Message that the safe is airtight
delay(2000); // Filibuster 2000 miliseconds }
lcd.articulate(); // Clear LCD
mainLCDMenu(); // Either way, go back to primary carte }
else if (key == '3'){ // If "Set code" choice is selected
lcd.clear(); // Clear LCD
lcd.print ("Enter 1st key:"); // The code that follow is a repeat of code in option 1 lcd.setCursor(0,one); // The user has to enter the password successfully earlier changing it
while (entry[0] == NO_KEY)
{ entry[0] = keypad.getKey(); }
lcd.print(entry[0]);
delay(1000);
lcd.clear();
lcd.print("Enter second cardinal:");
lcd.setCursor(0,1);
while (entry[1] == NO_KEY)
{ entry[i] = keypad.getKey(); }
lcd.impress(entry[1]);
delay(1000);
lcd.clear();
lcd.print("Enter 3rd key:");
lcd.setCursor(0,one);
while (entry[2] == NO_KEY)
{ entry[2] = keypad.getKey(); }
lcd.print(entry[two]);
delay(1000);
lcd.articulate();
if ((entry[0] == password[0]) && entry[1] == password[1] && entry[2] == password[ii]) // If the password was correctly entered, this logic executes
{ password[0] = NO_KEY; // Reset the password value 0 to NO-Cardinal countersign[i] = NO_KEY; // Reset the password value 1 to NO-KEY countersign[ii] = NO_KEY; // Reset the password value 2 to NO-KEY
lcd.impress ("Gear up 1st key:"); // Set showtime key value
lcd.setCursor(0,ane);
while (countersign[0] == NO_KEY) // Loops endlessly until valid fundamental printing received { password[0] = keypad.getKey(); // Sets password[0] to new value } lcd.print(password[0]); // Prints out new value
delay(1000);
lcd.clear(); // Clear LCD
lcd.impress("Set 2d central:"); // Message for 2d key
lcd.setCursor(0,1); // Motion code
while (password[1] == NO_KEY) // Loops incessantly until valid fundamental press received { password[ane] = keypad.getKey(); // Sets password[1] to new value } lcd.impress(password[one]); // Prints out new value
filibuster(one thousand); // Delay 1000 miliseconds
lcd.clear(); // Clear LCD
lcd.print("Set 3rd key:"); // Message for 3rd fundamental
lcd.setCursor(0,1); // Motility cursor
while (password[ii] == NO_KEY) // Loops endlessly until valid key press received { password[two] = keypad.getKey(); // Sets password[ii] to new value }
lcd.print(countersign[2]); // Prints out new value
filibuster(thou); // Delay 1000 miliseconds
lcd.articulate(); // Articulate LCD }
else // This executes if the user enters the wrong password for verification prior { // to irresolute the password. User cannot modify password without knowing the password
lcd.clear(); // Clear LCD
lcd.print("Invalid code."); // Invalid code message
delay(chiliad); // Filibuster 1000 miliseconds
lcd.articulate(); // Clear LCD }
mainLCDMenu(); // Regardless of event, become back to the main menu
} }
Footstep 5: Concluding Product
In one case the final spiral is tightened, savour!
Be the First to Share
Recommendations
-
Anything Goes Contest
Source: https://www.instructables.com/Lego-Head-Safe/
0 Response to "How To Make A Lego Safe Mini"
Post a Comment