ECE 4180 Bluetooth Vending Machine

Remote Vending Machine

Group Member: Kedeng Pan, Yichen Ju.

DESCRIPTION

This design is created for ECE 4180 final project. The inspiration of the project concept comes from the more and more mobile payment devices evolving these days. A remotely controlled vending machine would be possible to replace the traditional ones.

Our prototype vending machine is made of wood pieces in the exterior design. The interior dispensing mechanism is achieved with DC motor and iron wire just as the normal vending machine for snacks. All interaction with user will be achieved through Bluetooth and uLCD screen. Users can choose to make a purchase from their mobile device by tapping button 1. This process simulates the actual payment and will dispense the product from the storage. Meanwhile, the remaining balance shown on uLCD will decrease and users can choose to add money by clicking the button 2 on their device. When there is insufficient amount of money, a warning alert will show in the uLCD with warning sound from speakers.

PARTS LIST

SCHEMATICS

/media/uploads/kedeng0/test.png

SOURCE CODE

main.cpp

#include "mbed.h"
#include "uLCD_4DGL.h"

DigitalOut myled(p21);
Serial blue(p28,p27);
DigitalOut motor(p22);
uLCD_4DGL uLCD(p9,p10,p11);
PwmOut speaker(p26);
//Servo servo(p23);



int money = 5;

void printBalance() {
    uLCD.cls();
    uLCD.color(GREEN);
    uLCD.printf("\nWelcome!\n"); //Default Green on black text
    uLCD.printf("\nYour Balance is:");
    uLCD.text_height(4);
    uLCD.text_width(4);
    uLCD.color(RED);
    uLCD.locate(1,2);
    uLCD.printf("%2D", money);

}

int main() {
    char bnum;
    printBalance();
       
    while(1) {
        if (blue.getc()=='!') {
            if (blue.getc()=='B') { //button data
                bnum = blue.getc(); //button number
                if (bnum == '1') {
                    if(blue.getc() == '1') { 
                        if(money >= 5) {
                            uLCD.cls();
                            uLCD.color(GREEN);
                            uLCD.printf("Vending.....");
                            wait(0.5);
                            motor = 1;
                            myled = 1;
                            speaker.period(1.0/500.0); // 500hz period
                            speaker =0.5;
                            wait(0.5);
                            motor = 0;
                            myled = 0;
                            speaker = 0.0;
                            uLCD.cls();
                            uLCD.printf("Sucess");
                            wait(0.5);
                            money -= 5;
                            printBalance();
                        } else {
                            uLCD.cls();
                            uLCD.printf("WARNING:\nInsufficient Balance!\n");
                            speaker.period(1.0/1000.0);
                            speaker = 0.5;
                            myled = 1;
                            wait(2);
                            speaker = 0.0;
                            myled = 0;
                            printBalance();              
                        }
                    }               
                } else if (bnum == '2') {
                    if(blue.getc() == '1') {
                        uLCD.cls();
                        uLCD.color(GREEN);
                        uLCD.printf("Recharging....\n");
                        myled = 1;
                        wait(1);
                        uLCD.cls();
                        uLCD.printf("Success\n");
                        money = money + 5;
                        wait(0.5);
                        myled = 0;
                        printBalance();
                    }
                }    
            }
        }
    }
}

PHOTOS

/media/uploads/kedeng0/front.jpg Frontview of Vending Machine.

/media/uploads/kedeng0/breadboard.jpg Breadboard Closeup

VIDEO


Please log in to post comments.