Final Project Journal

Project Ideation

1- Tell us about the idea of your project. Why do you care about this? What were you inspired by? Include images and videos of similar projects




What inspired me also and encouraged me to proceed with my idea is finding Michael Henry's (Meet & Treat) and Nihal Emad's (Vendorama) final projects. Their projects were similar to the idea I had in my mind, except for the gamification feature that I wanted to add.  

My project idea is to make a Smart Candy Box using Arduino that dispenses candy, just like a vending machine, by playing a simple game and then winning a treat.  

What inspired me to make this box is the need for creative ideas to grab visitors' attention during events and exhibitions. My current job requires my team and me to participate in many events, and we always need to come up with fun and innovative ideas to attract visitors to our booth. The Smart Candy Box is a great way to attract booth visitors; it can be a fun and engaging activation game to get people involved and excited about visiting our booth. 

Project Construction

2- Explain the CAD process of your project. How did you use the software to design your project? (List the softwares/tools/materials...etc that you used)

I used Autodesk Fusion 360 to create the Smart Candy Box design and to laser cut its multiple parts in 2.5D. I started by measuring the components and deciding on the box's dimensions (20cm x 20cm). I also decided to make it look like a candy shape with 10 parts in total and to assemble the parts using the T-slot joints. 

Then I created a new component, a new sketch, drew a rectangle, created the T-slot design for the M3 screw and nut, created grooves, and drew 3 mm circles for the screws and nuts. I used several constraints for the design, such as coincident, collinear, midpoint, and horizontal/vertical. I also measured the dimensions of the components, where each component would be mounted on the box, and I created the sketch for each part accordingly. I repeated the same process for the rest of the parts. 

Next, I made sure that everything was fully defined/fixed and in a separate component for the joint assembly. Then, I extruded each part into a 3 mm 2.5D part, changed their appearance, grounded the base, and assembled each part with a rigid joint. I also mounted the components onto the box, assembled them together, and made minor adjustments to make sure everything fits perfectly. 

Finally, I exported the multiple parts in *.DXF format using the Save DXF for Laser Cutting plugin. Also, I used LaserWork V6 to prepare the Smart Candy Box parts for laser cutting and saved the file in .rld format.

Screenshare - 2023-04-29 10_19_56 PM.mp4

I kept thinking of a creative way to attach the vending coil spring to the DC motor when it rotates, and I designed this holder part as a 3D print to bind them together using Autodesk Fusion 360. I projected the DC motor to get the dimensions for the holder and added 0.3 mm because of the 3D print shrinkage ratio. I created the holder as 3 parts: one for the DC motor and 2 for the coil spring to go in and out of. Then, I extruded the parts into a 3D part and assembled the 3 parts together as a rigid group to be 3D printed. Finally, I mounted the holder onto the DC motor to make sure it fits and exported the part in *.STL format to use Ultimaker-Cura to prepare it for 3D printing. 

Screenshare - 2023-04-29 10_45_59 PM.mp4

3- Explain the fabrication process of your project. How did you use the machine to fabricate your project? (List the softwares/tools/materials...etc that you used)

I used LaserWork V6 to prepare the Smart Candy Box to laser cut the 10 parts using El Malky ML149 CO2 Laser Cutter to make my multipart design on a plywood 3mm sheet.

I started by importing the .DXF files into LaserWork, then moved them to be right next to the origin (the green square). Also, I set the settings to cut mode with speed 30 and power 50. Scan mode for the text was set to 300 speed and 15 power. After that, I checked the preview, and everything looked good. Finally, I saved the file in .rld format and downloaded it to the laser cutter.

To fabricate/laser cut the Smart Candy Box, I downloaded the file to the laser cutter machine and used the arrow keys to select my file. Then, I placed a plywood sheet in the laser cutter and adjusted the focus. Also, I made sure that the origin was in the right place and tracked the frame of the laser cut to make sure it would fit the plywood sheet. Finally, I closed the machine's cover and pressed on start. It took 11 minutes and 42 seconds in total to finish laser cutting all parts.

IMG_4403.MOV
IMG_4404.MOV

I used Ultimaker-Cura to prepare the coil spring holder and top lid handle to 3D print them using PRUSA i3 Mk3/Mk3s 3D printer and white PLA 3D printer filament.

I started by dragging and dropping the .STL files into Cura, then I clicked slice. I adjusted the parts' position to lay flat on the 3D printer bed and I rotated them. Then, I changed the print settings to the appropriate parameters with brim adhesion and support.

After that, I sliced the parts and the result was 36 minutes and 8g. Finally, I exported the file in .gcode format, named it as the estimated time and weight of the print, and put it on an SD card.

To fabricate/print the 3D parts, I inserted the SD card that has my sliced models into the 3D printer. Then, I clicked the control knob to access the printer's settings, selected my file, changed the filament to white, and waited a couple of minutes to preheat the bed and print out what was left from the old filament. Finally, I started printing.

IMG_4457.MOV

Project Electronics & Power Management 

4- Describe your electronic circuit. What are the input and action components? What is the function of each? How do the components integrate together to form your smart system? (List the softwares/tools/components...etc that you used)

I used Tinkercad to design and simulate the Smart Candy Box's circuit to make sure it was functional before being prototyped on an actual breadboard. After that, I used Arduino IDE to write and program Arduino C text code; then uploaded the code to the Arduino board.

To build the Smart Candy Box, I used the following components and materials:

IMG_4589.MOV

The idea for the Smart Candy Box is for the user to activate the LCD screen characters when he/she comes close to the box. Then, push the button when the buzzer makes a beep sound. After that, the buzzer will make a second sound, the DC motor will rotate, the attached spring coil will push the candy bar, and the NeoPixel sticks will turn on and change colors. 

To do that, I started by designing and simulating the circuit for the Smart Candy Box using Tinkercad. I dragged the components from the menu bar and used the L293D motor driver because there's no L298N driver in Tinkercad. The motor driver controls the DC motor's rotational direction and speed. Also, I used an Arduino UNO board to control the smart device inputs and outputs as follows:

1- Ultrasonic sensor to measure the distance between the user and the sensor, then activate the LCD screen

2- Pushbutton for the user to push it to rotate the DC motor, make a sound, and turn on the NeoPixels

3- On/off switch to power the Smart Candy Box

1- The LCD screen will display this sentence when activated from the ultrasonic sensor: "When you hear the beep, press to win a treat!" 

2- The buzzer will make a beep sound, and when the user pushes the button, it'll make a second sound

3- The DC motor will rotate with the coil spring attached to it, and it'll push the candy bar out

4-  The NeoPixel sticks will turn on, emit light, and change colors

Then, I connected the components to my circuit and used the following pins on the Arduino:

I started implementing and breadboarding the physical circuit with an Arduino board and components. I wired the components together following my Tinkercad design. I wired the Arduino 5V pin to the positive channel of the breadboard, the VIN pin to the 9V positive channel, and the GND to the negative channel. Then, I wired the ultrasonic sensor GND, VCC, Echo, and Trig pins. Also, the pushbutton to pin 2. 

After that, I wired the buzzer to pin 9 (positive) and 2 NeoPixels to pin 8. Then, I wired the LCD screen to the Arduino's analog pins, SDA to pin A4 and SCL to pin A5. Finally, I connected the L298D motor driver to the DC motor and Arduino pins 6 & 7.

Once the wiring for the circuit was complete, I connected the Arduino board to my laptop and continued working on the Arduino C text code using Arduino IDE.

5- What is your power source? How did you select the suitable power source for your project? (List the softwares/tools/components...etc that you used)

The power source for the Smart Candy Box is 9V-2A adapter for the Arduino. I can power the device by connecting the adapter to the Arduino directly, but I chose to add a DC barrel jack adapter - female instead to avoid the plugging and unplugging of the adapter and damaging the Arduino.

DC motor and L298D dual H-bridge motor driver take 9V from the Arduino's Vin pin. 

The rest of the components (ultrasonic sensor, pushbutton, NeoPixel stick - 8 LED strip, piezo buzzer, and LCD) take 5V from the Arduino's 5V pin. 

Project Programming

6- Describe the code of your project. How did you program each function of the project?  

To build the code that would be uploaded to the Arduino board, I installed 2 libraries and used their examples: the LiquidCrystal_I2C for the LCD screen and Adafruit_NeoPixel for the NeoPixel 8 LED strip. Then I defined the Arduino pins and added the ultrasonic sensor code. After that, in the void setup that runs only once at the beginning, I set the function pinMode to either input or output (the pushbutton is input_pullup). Next, in the void loop, which's a function that executes indefinitely until the power is off, I set the ultrasonic distance to 20 cm to activate the LCD screen. The LCD screen will display this sentence when activated from the ultrasonic sensor: "When you hear the beep, press to win a treat!". After that, there'll be 3 seconds delay, and the buzzer will make a beep sound. Then, if the pushbutton is pushed (low), three actions will happen simultaneously: 

Finally, I compiled the code and resolved the bugs, then uploaded the code to the Arduino board and it worked perfectly.

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

#include <Adafruit_NeoPixel.h>

#ifdef __AVR__

#include <avr/power.h>

#endif

#define PIN 8

#define NUMPIXELS 8 

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 500  

long readUltrasonicDistance(int triggerPin, int echoPin) {

 pinMode(triggerPin, OUTPUT);  

 digitalWrite(triggerPin, LOW);

 delayMicroseconds(2);

 digitalWrite(triggerPin, HIGH);

 delayMicroseconds(10);

 digitalWrite(triggerPin, LOW);

 pinMode(echoPin, INPUT);

 return pulseIn(echoPin, HIGH);

}

int pushbutton = 2;

int motor1 = 7;

int motor2 = 6;

int buzzer = 9;

int NeoPixels = 8;


void setup() {

 pinMode(pushbutton, INPUT_PULLUP);

 pinMode(motor1, OUTPUT);

 pinMode(motor2, OUTPUT);

 pinMode(buzzer, OUTPUT);

 pixels.begin();

}

void loop() {

 lcd.init();

 lcd.backlight();

 if (0.01723 * readUltrasonicDistance(4, 3) < 20) {

   lcd.setCursor(0, 0);

   lcd.print("HELLO & WELCOME!");

   lcd.setCursor(7, 1);

   lcd.print(":)");

   delay(3000);

 lcd.clear();

   lcd.setCursor(1, 0);

   lcd.print("WHEN YOU HEAR");

   lcd.setCursor(4, 1);

   lcd.print("THE BEEP");

   delay(3000);


   lcd.clear();

   lcd.setCursor(2, 0);

   lcd.print("PRESS TO GET");

   lcd.setCursor(4, 1);

   lcd.print("A TREAT!");

   delay(3000);

   analogWrite(buzzer, 1000);

   delay(100);

   analogWrite(buzzer, 0);

   delay(100);

   analogWrite(buzzer, 1000);

   delay(100);

   analogWrite(buzzer, 0);

 } else {

   lcd.clear();

   analogWrite(buzzer, 0);

 }

 if (digitalRead(pushbutton) == LOW) {

   tone(buzzer, 3000, 1000);

   delay(100);

   tone(buzzer, 3000, 1000); 

   delay(100);

   tone(buzzer, 3000, 1000); 

   delay(100);

   digitalWrite(motor1, HIGH);

   digitalWrite(motor2, LOW);

   delay(500);

   digitalWrite(motor1, LOW);

   digitalWrite(motor2, LOW);

   pixels.clear();

   for (int i = 0; i < NUMPIXELS; i++) {

     pixels.setPixelColor(i, pixels.Color(255, 0, 0));

     pixels.show();

     delay(200); 

     pixels.setPixelColor(i, pixels.Color(0, 150, 0));

     pixels.show();

     delay(200); 

     pixels.setPixelColor(i, pixels.Color(255, 255, 0));

     pixels.show(); 

     delay(200); 

     pixels.setPixelColor(i, pixels.Color(0, 0, 255));

     pixels.show(); 

     delay(200);

     pixels.setPixelColor(i, pixels.Color(0, 0, 0));

     pixels.show(); 

     delay(200);

   }

 }

}

Project Integration & Testing 

7- Demonstrate with text and visuals how did you integrate the project’s modules together? What are the testing results? (Include a Demo video separately, showing a proof of functionality)

IMG_4267.MOV

I started implementing, breadboarding, developing the code, and testing the physical circuit one component at a time with an Arduino board to check that everything was working. I connected the DC motor to the L298D motor driver to control the rotation direction and speed. Then, I wired the NeoPixel sticks and downloaded the Adafruit_NeoPixel library. After that, I connected both components to a pushbutton and added the buzzer. Next, I moved to the wiring and testing of the LCD and downloaded the LiquidCrystal_I2C library. Then, I connected the Ultrasonic sensor and programmed it to be an input for the LCD.

After I was done with the smart circuit and code, I moved to the design of the enclosure for the Smart Candy Box using Fusion 360 and mounted the components (virtually) to make sure everything was in place. Then, I fabricated the enclosure using the laser cutter for everything except the coil spring holder and top lid handle; I used the 3D printer. 

Next, I started assembling the parts together using screws and nuts. Also, I integrated the circuit inside the box, mounted the components (physically), and made the necessary adjustments (extended the jumper wires) to make sure everything fit in its place. Then, I twisted a 2mm steel wire around a spray can to create the coil spring for the vending machine part and attached it to the 3D print holder and DC motor. After that, I added hinges and the top lid handle.

Finally, I added some candy bars to the vending machine and connected the Smart Candy Box to a power source to test its functionality. There were some issues, so I checked all the jumpers with Avometer, arranged all the wires and taped them down (secured in place using tape), and it worked perfectly. 

Inside the box

Top view

Top view without the lid

Switch the button on to power the box

LCD on and ultrasonic sensor not activated yet

Ultrasonic sensor activated 

"Hello & Welcome"

"When you hear the beep"

"Press to get a treat!"

Beep sound from buzzer

Press the pushbutton

DC motor rotates and the attached spring coil pushes the candy bar out

NeoPixel sticks turn on and change colors

IMG_4967.MOV

NeoPixel sticks will turn on and change colors

The Smart Candy Box dispenses candy just like a vending machine

IMG_4944.MOV

Sharing & Collaboration 

8- Did you ask for feedback? What are the ideas that others have contributed or suggested? What was someone else’s idea that you built upon? How did you help your peers? How did your peers help you?

I asked for feedback on the Fusion 360 design for the  Smart Candy Box from my instructors, Adel and Amany. Amnay suggested that I add 0.3 mm for the coil spring holder that will be attached to the DC motor. I already added 0.2 but I changed it to 0.3 just to be safe and it fitted the DC motor when I 3D printed it.

Also, my peer Yosra Eslam suggested that I use brass wiring clips/connectors instead of crocodile wires for the pushbutton and on/off switch. It was a lot neater and more stable.

Overcoming Challenges 

9- When you got stuck, what/who did you turn to? At what point did you have to pause to research or learn more before moving on? What are some mistakes, pitfalls, or challenges that others can avoid if they were doing this project?

I faced so many challenges but the biggest one was the T-slot grooves didn't fit together when I assembled the parts. I checked my Fusion 360 design to make sure the grooves were 3 mm and indeed they were. My next guess was that the plywood I used for the laser cutter wasn't 3mm. The Fab Lab specialist suggested I use sanding paper, so I spent hours sanding every groove until they fit together.  

I also didn't find long enough screws to hold the DC motor in its place. So I used a 2mm steel wire to tie it from the back and keep it in place while rotating. 

Future Work

10- If you had more time, what is one thing you would change/ Do next in your project?

I wanted to dispense the candy by playing and winning a game first, the game is "HitTheNumber!" from week 0 of the Maker Diploma. The game begins by providing the player with a random number from 1 to 100 on the LCD screen, which they should keep in memory. Then, a counter starts to count from 1 to 100, and the player should press the pushbutton on time when the correct number comes up on the screen. When the pushbutton is pressed on time, the player wins, and the device dispenses a candy treat. If not, the player loses and gets to play again. Unfortunately, I wasn't able to make it happen. I developed the code for the game separately but failed to integrate it with the other components' code.  

I also tried the Endless Run Game and I found the code for it on Instructables. However, it didn't work as well when I tried to add its code to the components' code.

In addition, some nice-to-have features that I wanted to add are a weight sensor system that detects when the candy supply is running low and automatically notifies me (via Bluetooth) to refill the box. And a servo motor that opens the device's door to get the candy after it has been dispensed.

IMG_5028.MOV

HitTheNumber!

IMG_5025.MOV

Endless Run Game

 Final Project Files