ProjectJADE
Project JADE, Junior Allergy Defense Enterprise, is a simple 3D-printed machine that consists of a box with electric components and circuits to sort candy based on the allergens the candy contains.
Based on preliminary research, 20% of the population suffers from a food allergy. We found that food allergies often deter people from trick or treating due to deadly allergens that cause severe allergic reactions.
To solve this problem, we developed Project JADE to make candy distributed on Halloween more accessible and safe for all trick or treaters. The project uses machine learning to determine whether or not candies have peanuts or not; then, a side swiper will direct the candy into the appropriate designated peanut/non-peanut chamber. The trick or treater will then use an interface to indicate whether or not they are allergic to peanuts. Based on the user input, the respective trap door in the storage chamber will open, dispensing candy that is safe for them to consume.
Supplies
Required Supplies(number in parenthesis indicate number components required):
Number of Components not accounted for in the Image
*Not Shown in Image
- 3D filament (Polylactic Acid)
- Lead-Free solder
- Webcam with USB (1)
- Arduino Uno (3)
- 22-gauge wires (red, black, white)
- USB-B (2)
- AA batteries (10)
- Black Round Rocker On/OFF Switches (2)
- VEX Servo Module (2)
- VEX Drive Shafts (2 12” shafts)
- 12V LED light*
- 3-pin 1-meter long RGB LED strip
- Assorted VEX screws
- Vex Keps Nuts
- Wire Nuts*
- Hershey's Miniature Assorted Chocolate Candy
- Painters Tape
- Duct Tape
- Hot glue Sticks
- Four AA battery casing (2)
- Three AA battery casing(1)
- Two AA battery casing(1)
Required Tools:
- Soldering Iron
- Power Drill
- 0.152 inch Drill bit
- 0.5 inch Drill bit
- Optional 0.7 inch Drill Bit
- Screw Driver
- Hot Glue Gun
- Sandpaper or Filer
- 3D printer
- Hammers
- 25 mm Star Screwdriver Bit
3D Printing Components
To start, 3D print all the linked files. Load the 3D Printer filament (PLA) into the 3D printer and start printing one component at one time. We recommend printing with 15% infill.
The following components require several of them:
Support Structure - 4x
Servo Holder - 3x
Connectors - 6x
**The Image above is just a snapshot of what some of the 3D components will look like**
Assembling the Base Structure and Two Chamber Box
A total of four holes will be drilled using the 0.152 inch drill bit in order to connect the Storage Candy Holder and Support Structure.
- Orient the Support Structure in the vertical position.
- Drill two holes on the upper half.
- Drill another two holes on the lower half.
- Align the support structure, Storage Candy Holder, and Candy Dispenser vertically as seen in the picture above.
- Then drill holes into both the Storage Candy Holder and Candy Dispenser that closely align with the holes previously drilled on the support structure.
- After all holes have been drilled, place screws in all the holes and place keps nut on the other end and tighten.
*The exact location of screws do not have to match the image due to the DIY aspect of this project.*
Attaching the Building Sorting Mechanism and Detection System
This mechanism is for detecting what type of candy is present and directing the candy in the proper box.
- Fit the Candy Sorter Lever Chamber below the final version detection box.
- There should be a space between the candy Sorter Lever Chamber and the final version detection box for the candy sorter rotator to fit.
- On the arms of the Candy Sorter Lever Chamber sticking up the sides of the detection box, drill two holes through each arm and through the detection box.
- Insert screws through the four holes (two on each arm) such that it goes through the arm and into the detection box.
- Secure screws inside the detection box with screw nuts.
- In the rear of the machine, hot glue connectors to a servo holder (with a VEX servo inside) onto the back of the storage candy holder, with the shaft hole facing upward.
- Attach the candy sorter rotator to a VEX drive shaft, and fit the drive shaft securely into the VEX servo.
- Align candy sorter rotator such that it fits into the space between the detection box and the lever chamber.
Installing the Trap Doors
The trap doors will keep the candy into the two distinct chambers before dispensing to the Trick or Treater.
- Orient the Storage Candy Holder with the Detection Box with the trick or treat tray pointing to the left.
- In the upper left hand corner, use the 0.5 inch drill bit to drill a hole through both the outer wall along with the inner wall.
- Re-orient the Storage Candy Holder with the Detection Box with the trick or treat tray pointing to the right.
- About 0.25 inches below the center of the last hole drill, use the 0.5 inch drill bit to drill through both the outer wall and inner wall.
- Insert the Axle through the trap door and connect the axle to the servo output.
- Repeat for both sides.
- Refer to the image.
Bringing All Mechanical Components Together
Finish up combining the mechanical components of Project JADE.
- Vertically align the Detection box with the protruding support structure of the candy storage container.
- Orient two Support Structures vertically and insert in between the detection box and protruding support structure.
- Using the 0.152 inch drill bit, drill two holes on the upper portion of the support structure.
- Place two screws in each hole and use a keps nut for each screw to hold the structures in place.
- Once again use the 0.152 inch drill bit to drill a hole in approximately the center of the protruding structure that results in a long hole through the protruding Support Structure and halfway through the detection box.
- Screw in a screw to secure the components together. (A keps nut is not required due to the friction and tightness of the 3D components.)
- Repeat these steps for the other side of the detection box.
- Using either the 0.5 or 0.75 inch drill bit, drill approximately four holes around the detection box that will later be used for wire management..
- Place Servo in Servo Holders.
- Using hot glue to attach the connectors to the sides of the servo and then hot glue them onto the box in the proper position as shown in the picture.
Establishing Electrical Connections
For the electrical connections, please note that there are multiple ways to connect the components together including soldering, wire nuts, or jumper wires. The project shown combines both wire nuts and soldering for electrical connections.
12V light
- Connect the two Four AA battery casings in series by attaching the red wire of one casing to the black wire of another casing.
- Attach the unconnected red wire to one prong of the Black Round Rocker On/OFF Switch.
- Using 22 gauge wire, attach one end to the other prong of the switch and the other end to the positive terminal of the 12V light. Best to use red wire in this scenario to illustrate positivity of the wire.
- Connect the black wire of the battery casing to the negative terminal of the 12V battery.
LED String Light
- Connect the three AA battery casings with the two AA battery casing to create a series circuit by attaching the red wire of one casing to the black wire of another casing.
- Attach the unconnected red wire to one prong of the Black Round Rocker On/OFF Switch.
- Using 22 gauge wire, attach one end to the other prong of the switch and the other end can be inserted into the Arduino VIn. Once again, it’s best to use red wire in this scenario to illustrate positivity of the wire.
- The black wire of the battery casing can be connected to any of the Ardunio’s ground ports.
- Connect three different 22 gauge wires to the three inputs of the LED string light.
- The wire connected to the 5V input will be plugged into the Arduino’s 5V port.
- The ground wire will be connected to a Ardunio ground port.
- Lastly the signal/comm wire will be connected to Arduino Port 6.
Servo Motor Connections- Trap Doors
- Place a new Arduino into the electronic storage container.
- Connect the white wire of the Vex Servo Motor through the pre-drilled holes (for wire management) to connect to digital pin 9 (peanut chamber).
- Connect the Orange prong of the Servo Motor through the pre-drilled hole to digital pin 9.
- Lastly connect the black prong to the Arduino Ground port.
- Repeat these steps but instead connect the orange to digital pin 10 (non-peanut chamber).
Side Swiper Connection
- Place a new Arduino into the electronic storage container.
- Connect the white wire of the Vex Servo Motor through the pre-drilled holes (for wire management) to connect to the Arduino port 9.
- Connect the Orange prong of the Servo Motor through the pre-drill hole to the 5V pin.
- Lastly connect the black prong to the Arduino Ground pin.
Place All Electrical Components Within Storage Box
If there are any other electrical components left outside of the designated electrical component section of the detection box, please ensure that all the electrical components are located in the box.
- Use the previously drilled holes as ports for wires that extend and connect to components outside of the box.
- Ensure to allot two holes for the Black Round Rocker On/Off switches, so they are easily accessible for turning on and off.
- If the hole is too large around the Black Round Rocker On/Off switch, use hot glue to secure the switch.
- Install the Box Cover by using any form of tape to secure it to the detection box.
- Use a hot glue gun to glue down the Screw Ramp as shown in the picture on top of the detection box.
- Use hot glue again to glue down the screw ramp cover as seen in the picture.
Adding Computer Science Functionality
If there are any other electrical components left outside of the designated electrical component section of the detection box, please ensure that all the electrical components are located in the box.
- Use the previously drilled holes as ports for wires that extend and connect to components outside of the box.
- Ensure to allot two holes for the Black Round Rocker On/Off switches, so they are easily accessible for turning on and off.
- If the hole is too large around the Black Round Rocker On/Off switch, use hot glue to secure the switch.
- Install the Box Cover by using any form of tape to secure it to the detection box.
- Use a hot glue gun to glue down the Screw Ramp as shown in the picture on top of the detection box.
- Use hot glue again to glue down the screw ramp cover as seen in the picture.
Step 6: Adding Computer Science Functionality
Please note that depending on the code editor you choose to use, you may have different buttons but these are a general guideline of how to set up our code. Many tutorials exist if you have problems with any step of this process as well! All files and folders that are referenced below can be found here: https://drive.google.com/drive/folders/172VY93GHf3B3EaNAtRmF2v18U7Hs7pxB?usp=sharing
Neural Network Customization
- If you are editing the Neural Network, read this. If not, you can skip this portion. Go to https://teachablemachine.withgoogle.com/train/image.
- Edit the class names to “Peanut” and “Non-Peanut”. Add another class and name it “Nothing”.
- Go to “Peanut” and hit the “Webcam” option and use the dropdown to select the USB-camera.
- Begin collecting images when the peanut candy is in frame.
- Try to collect at least 300 images with 15 images per candy as you drop them allowing the Neural Network to view the candy from different angles. Repeat this for non-peanut candies in the Non-Peanut class.
- For the Nothing class, have the camera record when no candy is in the chamber. Once complete, hit “Train Model” and wait for it to finish.
- Finally, click on “Export Model” and select “Tensorflow” and not Tensorflow.js and Tensorflow Lite. Make sure the “Keras” option is selected then select “Download my model”.
- Place the “converted_keras” that is generated into a folder called “keras” that should hold all of the scripts that are mentioned below.
Running Computer Vision on Arduino
- Plug in the camera USB and Arduino for the candy sorter rotator USB-B into your computer.
- Feed the cable through a hole in the detection box so that the Arduino and camera can be left inside the detection box.
- Download the “keras” folder. There should be TeachableMachineArduino.py, labels.txt, and keras_model.h5 inside it. Then, download move_Servo.ino and keep it outside the folder.
- Open the Arduino IDE or download it if you don’t have it.
- Navigate to the “Tools” tab in the upper left corner. Look for “Port” and make sure that you can see the Arduino Uno you are using and that the COM is correct. The “Board” option above it should have “Arduino/Genuino Uno” to ensure you are using the correct Arduino. Once confirmed, run the code by hitting the “Upload” button.
- Open the TeachableMachineArduino.py file. Make sure the “COM” in the file matches the one in the Arduino file. Run this by hitting the “Run” button atop the IDE of your choice.
Creating the Website
- Download IntelliJ through this link: https://www.jetbrains.com/idea/.
- Next, open the Spring Initializr website: https://start.spring.io/.
- Select “Maven” for Project and “Java” for Language. Choose the latest Spring Boot Version for stability. On the Project Metadata, use “candy-dispenser” for Artifact and “CandyDispenser” for Name. Select “Jar” for Packaging and the latest Java Version compatible with your setup. Under Dependencies, add “Spring Web” and “Spring Boot DevTools”. Generate and extract the .zip file to your computer.
- On IntelliJ IDEA, open the .zip file and wait for the Spring Boot project to sync dependencies. There will be a total of 3 Java files and a HTML file.
- In the Project view, navigate to “src/main/java”, create a new Java class and name it “CandyDispenserController.java”. This file will connect the API request for dispensing candy from the frontend HTML to the backend.
- Paste the code for your CandyDispenserController class.
- Create another Java class and title it “ArduinoCommunicator.java”. This class will send input to the Arduino for opening the trap doors.
- Paste the AdruinoCommunicator code into this class. The “CandyDispenserApplication.java” file will be created automatically when you open a new Spring Boot Project, but if it does not appear, make the new Java file and paste the code.
- Create your HTML file in “src/main/resources/static” and name it “index.html”. This file will be the main user interface website.
Running Trapdoors
- Download Arduino IDE using this link: https://www.arduino.cc/en/software/.
- Open a new sketch named “Trap Door Motors” and paste the provided code.
- Connect your Arduino board to your computer via USB and choose the port to which it is connected.
- Click on the upload button on the top left and wait till it is done compiling.
- Open the Serial Monitor and set the baud rate to 9600.
- Go back to the IntelliJ files and make sure that the name of the port in your serial communication matches the actual port to which your Arduino is connected.
- To test the application, right click on the “CandyDispenserApplication,java” class and choose “Run”.
- Go to your local browser (ex. chrome) and paste this url: http://localhost:8080 to showcase your HTML webpage.
- Click on the buttons and it should trigger a response to the Arduino to open the designated trapdoors.
Final Assembly and Test
Use the Black Round Rocker On/Off Switch to turn on the 12V LED light and the LED string light. Start by placing candy one by one down the ramp to start sorting. Please wait until the candy finishes sorting before placing the next piece of candy.
Decorate As You Desire!
Once the project is completed and everything works as you wish, feel free to decorate the project as you wish. Add a Halloween spin with spooky ghosts, flying bats, or jack o’ lanterns. The options for creativity are endless!
If you have any question, please reach out!
(626)-491-8728