DLD PROJECT Report

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

DLD PROJECT REPORT

ARDUINO VENDING MACHINE


Group # 1
Members:
Zaman Akmal
Ahmed Yahya
Arham Ali
Manahil Bashir
Rida Fatimah
Fatima Raza
Abstract:
This project outlines the development of a vending machine
using Arduino-based electronics technology. The project aims
to demonstrate the integration of digital logic design
principles, providing hands-on experience in electronics and
programming.

Introduction:
Digital logic design advancements have evolved the vending
machine industry. This project seeks to explore these
technologies by creating a vending machine prototype. The
project aims to offer an educational experience in digital logic
design by combining Arduino microcontroller programming
with mechanical components.

Objectives:
1. Design and construct a functional vending machine
prototype.
2. Implement digital logic circuits to control the vending
machine's operations.
3. Program Arduino microcontrollers to manage user
interactions, product selection, and dispensing.
4. Integrate sensors and actuators for detecting user input and
dispensing products.
5. Document the project to serve as an educational resource
for enthusiasts and students interested in DLD.
Methodology:
1. Component Selection: Choose appropriate electronic
components, including Arduino boards, sensors, and vending
mechanisms.
2. Circuit Design: Develop digital logic circuits to control the
vending machine's operation, including user input, product
selection, and dispensing.
3. Arduino Programming: Write code to interface with
sensors and manage user interactions, and control vending
machine functions.
4. Mechanical Design: Design and build the vending machine
enclosure, product dispensing mechanism, and user interface.
5. Testing and Iteration: Conduct thorough testing to ensure
the vending machine functions reliably and accurately. Iterate
on design and programming as needed to address any issues.
Circuit schematic:
Resources Used:
- Arduino board
- Electronic components (sensors, buttons)
- Mechanical components (enclosure materials, motors,
dispensing mechanisms)
- Tools for fabrication and assembly
- Budget allocation for component purchase and fabrication
costs
Expected Outcomes:
The vending machine project will result in a fully functional
prototype that dispenses selected products based on user
input. The project will serve as an educational resource for
individuals interested in Arduino programming, and digital
logic design.
Output:
 Complete Hardware and Software.
 Fully Functioning Components.
Limitations:
• The belts were not the right size, they came in short.
• The circuit worked before it was installed into the
hardware but when it was put in and the buttons were
changed the program stopped responding.
• The servo motors could not hold the springs available.
• Software and hardware are complete, bug could’ve been
figured out due to limited time.
Arduino Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 20, 4);
Servo servo1, servo2, servo3, servo4; // DS04-NFC motors
// Stepper motors pins
#define dirPinVertical 0
#define stepPinVertical 1
#define dirPinHorizontal 2
#define stepPinHorizontal 3
#define coinDetector 9
#define button1 13
#define button2 12
#define button3 11
#define button4 10
#define microSwitchV 15
#define microSwitchH 14
int buttonPressed;
void setup() {
// Initialize the Wire library (required for I2C communication)
Wire.begin();
// initialize the LCD
lcd.init();
// Turn on the backlight
lcd.backlight();
servo1.attach(4);
servo2.attach(5);
servo3.attach(6);
servo4.attach(7);
pinMode(dirPinVertical, OUTPUT);
pinMode(stepPinVertical, OUTPUT);
pinMode(dirPinHorizontal, OUTPUT);
pinMode(stepPinHorizontal, OUTPUT);
pinMode(coinDetector, INPUT);
// Activating the digital pins pull up resistors
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
pinMode(button4, INPUT_PULLUP);
pinMode(microSwitchV, INPUT_PULLUP);
pinMode(microSwitchH, INPUT_PULLUP);
// Vertical starting position
digitalWrite(dirPinVertical, HIGH); // Set the stepper to move in a particular direction
while (true) {
if (digitalRead(microSwitchV) == LOW) { // If the micro switch is pressed, move the
platform a little bit up and exit the while loop
moveUp(70);
break; }
// Move the carrier up until the micro switch is pressed
digitalWrite(stepPinVertical, HIGH);
delayMicroseconds(300);
digitalWrite(stepPinVertical, LOW);
delayMicroseconds(300);}
// Horizontal starting position
digitalWrite(dirPinHorizontal, LOW);
while (true) {
if (digitalRead(microSwitchH) == LOW) {
moveLeft(350);
break;}
digitalWrite(stepPinHorizontal, HIGH);
delayMicroseconds(300);
digitalWrite(stepPinHorizontal, LOW);
delayMicroseconds(300); }
// Print a message on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Insert a coin!");}
void loop() {
// Wait until a coin is detected
while (true) {
if (digitalRead(coinDetector) == LOW) { // If a coin is detected, exit from the while loop
break;}}
delay(10);
// Print "Select your item" on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Select your item");
lcd.setCursor(0, 1);
lcd.print(" 1, 2, 3 or 4?");
// Wait until a button is pressed
while (true) {
if (digitalRead(button1) == LOW) {
buttonPressed = 1;
break;}
if (digitalRead(button2) == LOW) {
buttonPressed = 2;
break; }
if (digitalRead(button3) == LOW) {
buttonPressed = 3;
break;}
if (digitalRead(button4) == LOW) {
buttonPressed = 4;
break;}}
// Print "Delivering..." on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Delivering...");
// Depending on the pressed button, move the carrier to that position and discharge the selected
item
switch (buttonPressed) {
case 1:
// Move the container to location 1
moveUp(4900); // Move up 4900 steps (Note: the stepper motor is set in Quarter set
resolution)
delay(200);
moveLeft(1700); // Move left 1700 steps
delay(300);
// Rotate the helical coil, discharge the selected item
servo1.writeMicroseconds(2000); // rotate
delay(950);
servo1.writeMicroseconds(1500); // stop
delay(500);
// Move the container back to starting position
moveRight(1700);
delay(200);
moveDown(4900);
break;
case 2:
// Move the container to location 2
moveUp(4900);
delay(200);
// Rotate the helix, push the selected item
servo2.writeMicroseconds(2000); // rotate
delay(950);
servo2.writeMicroseconds(1500); // stop
delay(500);
moveDown(4900);
break;
case 3:
// Move the container to location 3
moveUp(2200);
delay(200);
moveLeft(1700);
delay(300);
// Rotate the helix, push the selected item
servo3.writeMicroseconds(2000); // rotate
delay(950);
servo3.writeMicroseconds(1500); // stop
delay(500);
// Move the container back to starting position
moveRight(1700);
delay(200);
moveDown(2200);
break;
case 4:
// Move the container to location 4
moveUp(2200); // Move vertically 4800 steps
delay(200);
// Rotate the helix, push the selected item
servo4.writeMicroseconds(2000); // rotate
delay(950);
servo4.writeMicroseconds(1500); // stop
delay(500);
moveDown(2200);
break;}
// Print "Item delivered!" on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Item delivered!");
delay(2000);}
// Custom functions
void moveUp(int steps) {
digitalWrite(dirPinVertical, LOW);
for (int x = 0; x < steps; x++) {
digitalWrite(stepPinVertical, HIGH);
delayMicroseconds(300);
digitalWrite(stepPinVertical, LOW);
delayMicroseconds(300);}}
void moveDown(int steps) {
digitalWrite(dirPinVertical, HIGH);
for (int x = 0; x < steps; x++) {
digitalWrite(stepPinVertical, HIGH);
delayMicroseconds(300);
digitalWrite(stepPinVertical, LOW);
delayMicroseconds(300);}}
void moveLeft(int steps) {
digitalWrite(dirPinHorizontal, HIGH);
for (int x = 0; x < steps; x++) {
digitalWrite(stepPinHorizontal, HIGH);
delayMicroseconds(300);
digitalWrite(stepPinHorizontal, LOW);
delayMicroseconds(300);}}
void moveRight(int steps){
digitalWrite(dirPinHorizontal, LOW);
for (int x = 0; x < steps; x++) {
digitalWrite(stepPinHorizontal, HIGH);
delayMicroseconds(300);
digitalWrite(stepPinHorizontal, LOW);
delayMicroseconds(300);}}
References:
https://howtomechatronics.com/projects/diy-vending-
machine-arduino-based-mechatronics-project/
https://forum.allaboutcircuits.com/threads/diy-vending-
machine-a-to-z-help-needed.118695/

THE END

You might also like