$1 Arduino-based Vending Machine
by Tustin High T-Tech in Circuits > Arduino
17455 Views, 43 Favorites, 0 Comments
$1 Arduino-based Vending Machine
We got our idea from our engineering teacher - we all thought it would be a good idea to have a vending machine for our class and he said - "cool, make one". It turned out that a vending machine would be a great senior project and when complete would function as a fundraiser for our engineering program.
It is called a $1 Vending Machine not because it costs $1 to make, but simply because the bill acceptor is an older model that only takes $1 bills :)
Criteria
We wanted a vending machine that would fit on top of a desk and not be too tall. We took the dimensions of the width of the table to make sure we did not have the vending machine hanging off of the table.
Casing
We made our box 19 inches wide by 17 inches long by 25 inches tall.
We used a CNC Machine to cut our wood. We used solidworks to design the faces and then converted them to drawing file types for our CNC software. We sanded the edges and then screwed them in with 1 ¼”. We attached the front panel with a hinge and used ¼ “ screws, so that the screws would not go through to the other side. We also used Acrylic Glass which we cut for the shelves and front panel.
Electronics
Arduino
We used an Arduino Mega 2560 Board. We also used Adafruit Motor Boards so that they can run the stepper motors. We added pins to the adafruit's in order for them to connect to each other. They were inserted them on top of one another. Each one can run 2 motors. Also, please note that the jumper needs to be connected.
Desktop Power Supply
Bestek ATX Power supply using an adapter to keep the power supply on. The adapter is from sparkfun.com and provides various voltages.
Coils into Motors
We made solidworks models to hold the motor, grab the coil, and guide the coil along the shelf. We had attained our coils from ebay and cut them to dimension. We also had to bend 3 of them since we did not get 6 with the straight ends to connect to the coil mount. We then 3D printed them and attached them to the coil and motor. The stepper motors we had, we put into a mount. It would hold the motor and guide the coil along a straight path.
LCD and Keypad
We used an Arduino Keypad and LCD screen connected into a 5V lead on the power supply adapter for power and then into the same Arduino Board
Wiring
We recommend the usage of 18 gauge wires. In our case, we had to compromise by using various gauges because we ran out of 18 gauges
LED Strip
We used an LED strip to light up the machine. We connected it to a 12V lead on the power supply adapter. The LED strip we used thankfully had a + and - on it which made the process of connecting it easier.
Bill Acceptor
We used a Coinco BA30B as our bill acceptor. It had to be connected directly to the wall as a power source. We combined it with a 24-pin adapter from an atx power supply to plug in and allow easier wiring. The pinouts we followed are found in the following link:
http://techvalleyprojects.blogspot.com/2011/07/ard...
In our case, we had to create a mount to raise the bill acceptor because otherwise it would be too low for our casing.
Testing
Test the electronics outside the casing first to ensure that the components work. Any issues that arise should be fixed before placing them inside the casing.
Electronics to Casing
Once you've tested the electronics and are satisfied with their results, begin placing them into your casing. Adjust wire lengths to so that they fit comfortably inside.
Final Testing
Once placed into the casing, test everything again. If everything works as you expected, congratulations! You made a vending machine.
Arduino Code + Links
Downloads:
Arduino Code
https://drive.google.com/drive/folders/1oC4MhOcMFy...
SolidWorks Folder with part files and assembly
https://drive.google.com/drive/folders/1amZoypiWcZ...
Just in case something has happened to the link, here is the arduino code fully displayed.
Arduino Code <<
#include #include #include "Arduino.h" #include #include #include "utility/Adafruit_MS_PWMServoDriver.h" #include
const int stepsPerRevolution = 200; const byte ROWS = 4; //four rows const byte COLS = 3; //three columns char keys[ROWS][COLS] = { {'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'}, {'*', '0', '#'} }; byte rowPins[ROWS] = {5, 6, 7, 8}; //connect to the row pinouts of the keypad byte colPins[COLS] = {2, 3, 4}; //connect to the column pinouts of the keypad Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); Adafruit_MotorShield AFMS1 = Adafruit_MotorShield(); Adafruit_StepperMotor *myMotor1 = AFMS1.getStepper(-200, 1); Adafruit_StepperMotor *myMotor2 = AFMS1.getStepper(-200, 2); Adafruit_MotorShield AFMS2 = Adafruit_MotorShield(0x61); Adafruit_StepperMotor *myMotor3 = AFMS2.getStepper(-200, 1); Adafruit_StepperMotor *myMotor4 = AFMS2.getStepper(-200, 2); Adafruit_MotorShield AFMS3 = Adafruit_MotorShield(0x62); Adafruit_StepperMotor *myMotor5 = AFMS3.getStepper(-200, 1); Adafruit_StepperMotor *myMotor6 = AFMS3.getStepper(-200, 2); Adafruit_MotorShield AFMS4 = Adafruit_MotorShield(0x63); Adafruit_StepperMotor *myMotor7 = AFMS4.getStepper(-200, 1); Adafruit_StepperMotor *myMotor8 = AFMS4.getStepper(-200, 2); LiquidCrystal lcd(1, 11, 9, 10, 12, 13); //Digital Pins the lcd is connected to // Constants // // pin for the bill validator's credit(-) line const int billValidator = 22;
// Variables /
/ recording the duration of pulse (milliseconds) unsigned long duration;
// holding the total dollars recorded int dollarCounter = 0; void setup() { lcd.begin(16, 1); //set lcd text coordinates lcd.print(" Insert $1 Only"); //Set text Serial.begin(9600); // Initialize serial ports for communication. Serial.println("Stepper test!"); //Type Out Stepper Test in the serial monitor so that we know which stepper motor is pressed. AFMS1.begin(); AFMS2.begin(); AFMS3.begin(); AFMS4.begin(); myMotor1->setSpeed(100); //Set Motor Speed at which they will run myMotor2->setSpeed(100); myMotor3->setSpeed(100); myMotor4->setSpeed(100); myMotor5->setSpeed(100); myMotor6->setSpeed(100); myMotor7->setSpeed(100); myMotor8->setSpeed(100); // Pin setups for bill validator and button pinMode(billValidator, INPUT); //Sets the billaccepter
// Initialize serial ports for communication. Serial.begin(9600); Serial.println("Waiting for dollar..."); } void loop () { { duration = pulseIn(billValidator, HIGH); //Starts looking for the pulse length recieved from the bill acceptor if (duration > 12000) //Value of which it has to surpass in order to validate as a processed and authentic dollar { // Count dollar dollarCounter++; // Checking for understanding Serial.print("Dollar detected.\n Total: "); // Display new dollar count Serial.println(dollarCounter); //loop in order to wait until a button is pressed while (duration > 12000){ char key = keypad.getKey(); //gets the keyoad connected and starts to see which one is pressed if (key != NO_KEY) { //will be looking for key pressed Serial.println(key); //lets us know which one was pressed in the serial monitor } { if (key == '1') { //If Key 1 is pressed, does the following: int keyPressed = key - '1'; myMotor8->step(580, FORWARD, DOUBLE); //Starts Motor and rotates for 350 degrees in the forward direction. myMotor8->release(); //Releases the motor from the state of holding itself in place. return; //Goes back to the beginning of the loop code }
if (key == '2') { //If Key 2 is pressed, does the following: int keyPressed = key - '2'; myMotor7->step(400, FORWARD, DOUBLE); //Starts Motor and rotates for 350 degrees in the forward direction. myMotor7->release(); //Releases the motor from the state of holding itself in place. return; //Goes back to the beginning of the loop code } if (key == '3') { //If Key 3 is pressed, does the following: int keyPressed = key - '3'; myMotor6->step(400, FORWARD, DOUBLE); //Starts Motor and rotates for 350 degrees in the forward direction. myMotor6->release(); //Releases the motor from the state of holding itself in place. return; //Goes back to the beginning of the loop code } if (key == '4') { //If Key 4 is pressed, does the following: int keyPressed = key - '4'; myMotor5->step(180, FORWARD, DOUBLE); //Starts Motor and rotates for 350 degrees in the forward direction. myMotor5->release(); //Releases the motor from the state of holding itself in place. return; //Goes back to the beginning of the loop code } if (key == '5') { //If Key 5 is pressed, does the following: int keyPressed = key - '5'; myMotor4->step(6900, FORWARD, DOUBLE); //Starts Motor and rotates for 350 degrees in the forward direction. myMotor4->release(); //Releases the motor from the state of holding itself in place. return; //Goes back to the beginning of the loop code } if (key == '6') { //If Key 6 is pressed, does the following: int keyPressed = key - '6'; myMotor3->step(400, FORWARD, DOUBLE); //Starts Motor and rotates for 350 degrees in the forward direction. myMotor3->release(); //Releases the motor from the state of holding itself in place. return; //Goes back to the beginning of the loop code } if (key == '7') { //If Key 7 is pressed, does the following: int keyPressed = key - '7'; myMotor7->step(400, FORWARD, DOUBLE); //Starts Motor and rotates for 350 degrees in the forward direction. myMotor7->release(); //Releases the motor from the state of holding itself in place. return; //Goes back to the beginning of the loop code } if (key == '8') { //If Key 8 is pressed, does the following: int keyPressed = key - '8'; myMotor8->step(400, FORWARD, DOUBLE); //Starts Motor and rotates for 350 degrees in the forward direction. myMotor8->release(); //Releases the motor from the state of holding itself in place. return; //Goes back to the beginning of the loop code } } } } } } >>