Key Sorter Cardboard Project
I have made a cardboard project that keeps track of keys and alerts a person when a pair of keys were removed.
Here is a link to the key sorter in action: Link
Supplies
1) Cardboard (lots of it)
2) Hot Glue
3) Box Cutter
4) Wire Stripper
5) Argon (Particle product)
6) 2 switches
7) 2 Servos
8) 2 LEDs
9) If This Then That App (IFTTT) for Android or Apple products
If This Then That App
Lets Start with software portion of the project.
1) Open the App Store or Google Play Store on Android devices.
2) This way when we run the project multiple times you can block the text messages from sending and instead recieve a notification from the IFTTT app. Downloading the app is especially helpful if you have to pay for texts.
Creating the IFTTT Applets
We need to create our applets so it will be able to be called by the webhooks and the code.
Click this link for a video on how to make an applet in IFTTT
1) Open IFTTT in a new tab in your browser. Either way works but downloading the app is important if you do not want to pay for texts.
2) Press the Get Started button in the top right corner to create an account or log in if you already have an account.
3) Once you log in press the "Create" button in the top right corner by your profile.
4) Press the "Add" button next to "If This". Then type in webhooks into the search bar. Next, press the trigger on the right named "Receive a web Request". Give the event any name using only letters, numbers and underscores.
5) Press the "Add" button next to "Then That". Then type in Android SMS and press the "Send an SMS" trigger. Add the phone number you would like to communicate to and then add the message you want to be displayed when the applet is triggered. Then press continue and add a title. After that flip the switch to turn on "Receive notifications when this Applet runs". When your done with the applet, it should say it is connected, and then flip the switch to notify yourself when it runs.
Particle
Time to work on the software portion of the project.
1) Open the Particle login link in your browser.
2)Press the sign up button if you do not have an account yet, or login with your email and password if you do have an account.
3) We need to make an access token so you will be able to publish webhooks and access other things inside the Particle Cloud.
4) Open up the Particle Access Tokens and log in. Scroll down on the reference sheet to creating a browser-based token. Enter your email and password, then switch the expiration date to whatever you would like. Just make sure you give yourself enough time to make the project. Then create the token and keep it safe.
Coding
1)After logging in, click on the Web IDE tab on the left side of the screen.
2)First, add a title for your app.
Next, copy and paste my code into the console:
Servo myServo;
Servo myServo1;
int button = 5;
int button1 = 6;
int blue = 8;
int red = 4;
void setup()
{
myServo.attach(2);
myServo1.attach(3);
myServo.write(150);
myServo1.write(30);
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(button, INPUT_PULLUP);
pinMode(button1, INPUT_PULLUP);
}
void loop()
{
int buttonState = digitalRead(button);
int button1State = digitalRead(button1);
if (buttonState == HIGH)
{
digitalWrite(blue, HIGH);
myServo.write(30);
delay(1000);
myServo.write(130);
Particle.publish("Slot2Alert");
Particle.publish("Servo2");
digitalWrite(blue, LOW);
}
if (button1State == HIGH)
{
digitalWrite(red, HIGH);
myServo1.write(110);
delay(1000);
myServo1.write(30);
Particle.publish("ServoAlert");
digitalWrite(red, LOW);
}
}
3) Make sure to save the code.
Creating Webhooks
We need to create webhooks in order for us to use IFTTT and send texts to your phone.
1) To start, on the bottom left of the particle web screen, press the bar graph icon. This should open up a new tab.
2) After opening up the console, you should load into the events screen. On the left side of the screen directly under the events tab, press on the integration tab.
3) Press the create new integration button and then click on webhook integration. Give your event any name.
4) Now we need to grab our URL, so we need to go back to IFTTT. After you log in to IFTTT, press your profile icon in the top right. Then click the My Services tab. Scroll all the way down to the bottom and click on webhooks. Next, click on the documentation and follow the directions to make a POST web request. Make sure that you are getting your POST request from the part named "To trigger an Event with an arbitrary JSON payload". Delete the "{event}" and insert the name of your applet or webhook in the type box. The copy and paste the link you just made into the URL spot back in the webhook. Then press the create webhook button on the bottom.
Time to Build
Now that all the electronics are out of the way, it is time to build the physical device.
1) To start with the physical product you need a base layer of cardboard that is 15 inches by 12 inches.
2) In order to make the key holder make a box without one long side and without a top. My box has a length of 6 inches, width of 4, and height of 2 inches.
3) Building the key holders is very simple. Build a 4 inches by 4 inches by 1 inch square with no top, this is where the breadboard and all the wiring is going to go to. You will also need to build 2 squares that are 3 inches by 3 inches by 1 inch with no top or bottom. These 2 squares will actually be holding on to the keys.
4) For the guide rails on the side, make them the perfect length where they touch the top corners of the base cardboard and the top of the box. Mine are 13 inches long and 2.5 inches tall.
5) Next cut out 2, 3 inch by 3 inch pieces of cardboard that will end up being hooked on to the servos.
6) Now it is time to hot glue everything together. First, center the large key box at the very bottom of the base layer. Make sure there are no gaps. Next, line up the guide rails and glue them to the top of of the large key box to top corners of the base layer. Finally, glue the 3 inch squares next to the guide rails at the top on the inside but adjacent to each rail. Then glue the 4 inch squares directly in between the other 2 squares.
7) Next we need to insert the servos and the switches. For the servos, cut a small rectangle on the bottom corner of the 4 inch square and hot glue them in to place. Then put your 3 by 3 pieces of cardboard on to each servo fin. For the switches, put them on the outside of the guide rails but location does not really matter as long as they can function properly. To get them in, cut a small rectangle the size of the switch and hot glue it down.
8) For the LEDs poke small holes on the side of the 4 by 4 square so you can see them when looking at the build forward. You can hot glue them into place if you want to but it is not necessary for the LEDs.
9) All the building is complete. Now it is time to do all the wiring.
Setting Up the Argon and Wiring the Switches
You will need you breadboard, an argon, wires, 2 switches, 2 servos and 2 LEDs to finish this project.
1) Put the argon on the breadboard like shown in the picture below.
2) We are going to wire the switches first. You will need 2 wires for each switch.
3) Start with plugging the ground wire into the breadboard and then finding the ground leg on the switch. Plug the other wire into the object that you created for the switches.
Leave these wires when you do the next 2 parts of wiring.
Wiring the Servos
Step 1) Grab 3 wires for each servo.
Step 2) To make things less confusing, when plugging the wires into the servo, match the colors. (darkest color goes with brown servo wire, lightest color goes with orange servo wire and a color in between goes to the red servo wire)
Step 3) Start by plugging in the darkest wire into the ground pin. Plug the middle wire into the VUSB pin on the right side of the argon. Then plug the lightest wire into the object you are using for the Servo.
Leave these wires in as well when you do the next part of wiring.
Wiring the LEDs
1) Grab 2 wires for each light.
2) Put the LEDs inside the pins. Make sure to keep track of which wire goes with the longer leg of the LED.
3) Plug in the anode (longer leg) into the object pin you assigned to the LEDs. Plug the cathode (shorter leg) into the ground rail.
Now your project is completely wired. Your wiring may look very messy but that probably means you did it correctly. Here is an example of mine:
Final Steps
The Project is now complete. Plug your Argon into a power source and then flash the code to your Argon. After the code is flashed, press the buttons and you should have a working key sorter. Make sure to check your phone for a text notification or a notification from the IFTTT app telling you that keys were removed.
Now you have a place to store your keys and a way too keep track of them as well.