The idea of my project is to design a smart robot-shaped vending machine Instead of the traditional way of pressing buttons, this machine is interactive – when children or guests point at the robot, it responds by dropping sweets
360 fusion for 2D and3D modelling
overall design
Body parts
front
right side
back (made by projection )
left side (used copy & past tool)
parts in the back
fence in side the body
cut part for the top
Head parts
head part
bottom part
sides part (the second side, I copied and pasted it )
top part
Front part
Machine : El Malky ML149 Laser Cutter
I divided the process to 3 times every time with 1 sheet
I took the time from the CNC machine
Printer: Prusa MK3 3D Printer/ Prusa MK3 S Plus 3D Printer
PLA
holder for spring
shaft
connect H-bridge with DC motor in out 1 and out 2
connect the +ve of adaptor 9 v to the vcc of H-bridge
connect the -ve of the adaptor to the GND of arduino and the GND H-bridge
connect ena with pin 3
connect in1 with pin 5
connect in2 with pin 6
connect vcc of ultrasonic sensor with +ve of 5v
connect trig of ultrasonic sensor with pin 9
connect echo of ultrasonic sensor with pin 8
Connect VCC of LED matrix with +ve of 5V.
Connect CLK of LED matrix with with pin 13
Connect CS of LED matrix with with pin 11
Connect DIN of LED matrix with with pin 13
connect every lamp with resistor 32-0 ohm and connect them with analog pins
connect the +ve part of LED with resistor
connect all the GNDs together
connect the Arduino with 9V in Vin pin
. Connect the on/ off switch with pin 2
Input components:
Ultrasonic Sensor → detects when a person is pointing or standing close to the robot.
(Optional: Button/Switch if added) → could allow manual testing or controlling.
Action/Output components:
DC Motor + H-Bridge Module → drives the mechanism that releases the candies.
LED Matrix → displays “eyes” or animations, making the robot more lively and attractive.
LEDs → give visual feedback when the system is active.
Controller:
Arduino Uno → the brain of the system. It receives signals from the input (ultrasonic sensor) and then sends commands to the motor and LEDs accordingly.
Power Supply:
5V adaptor for LEDs and LED matrix
9V adaptor for the motor (converted to 5V for Arduino).
I used two adaptors because the components require different voltages:
5V adaptor → used to power the LED matrix, ultrasonic sensor and the LEDs.
9V adaptor → used to power the DC motor through the H-Bridge module, since the motor requires high voltage, then the 9V is transferred to 5V through the Vin pin in the Arduino
For programming, I used this app
Arduino IDE
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "MD_EyePair.h"
// ---------------- LED MATRIX ----------------
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 10
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
MD_MAX72XX M = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
#define MAX_EYE_PAIR (MAX_DEVICES / 2)
MD_EyePair E[MAX_EYE_PAIR];
#define DELAYTIME 500
// ---------------- ULTRASONIC SENSOR ----------------
#define trig 9
#define echo 8
float time = 0;
float distance = 0;
// ---------------- SWITCH ----------------
#define switchPin 2
// ---------------- MOTOR (H-BRIDGE) ----------------
int ena = 3;
int in1 = 5;
int in2 = 6;
// ---------------- DECORATIVE LEDS ----------------
#define led1 A1
#define led2 A2
#define led3 A3
#define led4 A4
#define led5 A5
// ---------------- SETUP FUNCTION ----------------
void setup() {
M.begin();
for (uint8_t i = 0; i < MAX_EYE_PAIR; i++)
E[i].begin(i * 2, &M, DELAYTIME);
pinMode(switchPin, INPUT_PULLUP);
// Setup ultrasonic sensor
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
digitalWrite(trig, LOW);
// Start serial monitor for debugging distance values
Serial.begin(9600);
// Setup decorative LEDs as outputs
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
// Setup motor pins as outputs
pinMode(ena, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
}
// ---------------- MAIN LOOP ----------------
void loop() {
// Check if the switch is ON (HIGH because of INPUT_PULLUP)
if (digitalRead(switchPin) == HIGH) {
// Animate the eyes on LED matrix
for (uint8_t i = 0; i < MAX_EYE_PAIR; i++)
E[i].animate();
// Turn on all 5 decorative LEDs
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
delay(1000);
// Trigger ultrasonic sensor
digitalWrite(trig, LOW);
delay(2);
digitalWrite(trig, HIGH);
delay(10);
digitalWrite(trig, LOW);
time = pulseIn(echo, HIGH);
distance = time * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm ");
if (distance <= 50) {
digitalWrite(in1, HIGH);
analogWrite(ena, 95);
delay(1090);
// Stop motor
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(1090);
}
}
else {
for (uint8_t i = 0; i < MAX_EYE_PAIR; i++)
M.clear();
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
analogWrite(ena, 0);
}
The LED matrix is programmed to display animated “eyes” using the MD_MAX72xx and MD_EyePair libraries.
A switch (with internal pull-up) is used to activate the whole system.
The ultrasonic sensor (with trigger and echo pins) measures the distance of a person in front of the robot. If someone comes within 50 cm, the robot activates its motor.
The motor is controlled through an H-Bridge. When triggered, it rotates for a short period (simulating candy dispensing), then stops.
Five decorative LEDs light up while the system is active, making the robot more attractive.
If the switch is OFF, the system clears the LED matrix, turns off all LEDs, and stops the motor.
First: I connected the DC motor with the H-bridge with the motor, then connected it with Arduino and put the ultrasonic sensor
second: I connected the LED matrix with the Arduino
after that, I connected all the LED matrix with 320 ohm resistor
I got feedback from Menna, my instructor. She gave me a lot of useful notes, she helped me to find the spring , and when the holder of the spring has wrong dimensions she told me to design the shaft
First problem: when I downloaded the holder, it was meshed, so I can't make a join between it and the DC motor
1) I used generate face group
I make it accurate and 0.001mm
It will appear like this
I choose to convert mesh
I made it parametric
Then I joined for it and the DC motor
Second problem: the spring makes an annoying sound because it hits the wood
so I used a Foam headband insert between the 2 sides of the spring to reduce this noise
I would make the head move by a servo motor and make space for another spring for candy