Ardino Powered Vending Machine

Introduction: Ardino Powered Vending Machine

We will show you the ins and outs of how to build a arduino/servo powered vending machine.

Step 1: Step 1:Cutting

We designed our vending machine to be 8x12x6 for more space to get our servo and arduino to fit perfectly inside.

Step 2: Step 2:Putting the Cut Pieces Together.

After we finished cutting everything for our vending machine, we started gluing our pieces together so we could figure out what to do next.

Step 3: Step 3:Painting Process

After we got most of our vending machine put together and cut out the doors and window, we starting sanding and painting.

Step 4: Step 4:Wiring Our Ardrino to the Servo and Breadboard.

Doing our project we wanted to have a sweep style servo code so that our snickers bars would vend properly through the correct holes in our machine. When searching for a code we came across we went on that website and found the exact code we were looking for.

// constant variables used to set servo angles, in degrees const int straight = 90; const int divergent = 110;

// constant variables holding the ids of the pins we are using const int divergent_led = 6; const int straight_led = 7; const int buttonpin = 8; const int servopin = 9;

// servo movement step delay, in milliseconds const int step_delay = 70;

// create a servo object Servo myservo; // global variables to store servo position int pos = straight; // current int old_pos = pos; // previous

void setup() { // set the mode for the digital pins in use pinMode(buttonpin, INPUT); pinMode(straight_led, OUTPUT); pinMode(divergent_led, OUTPUT); // setup the servo myservo.attach(servopin); // attach to the servo on pin 9 myservo.write(pos); // set the initial servo position // set initial led states digitalWrite(straight_led, HIGH); digitalWrite(divergent_led, LOW); }

void loop() { // start each iteration of the loop by reading the button // if the button is pressed (reads HIGH), move the servo int button_state = digitalRead(buttonpin); if(button_state == HIGH){ // turn off the lit led if(pos == straight){ digitalWrite(straight_led, LOW); } else { digitalWrite(divergent_led, LOW); } old_pos = pos; // save the current position // Toggle the position to the opposite value pos = pos == straight ? divergent: straight; // Move the servo to its new position if(old_pos < pos){ // if the new angle is higher // increment the servo position from oldpos to pos for(int i = old_pos + 1; i <= pos; i++){ myservo.write(i); // write the next position to the servo delay(step_delay); // wait } } else { // otherwise the new angle is equal or lower // decrement the servo position from oldpos to pos for(int i = old_pos - 1; i >= pos; i--){ myservo.write(i); // write the next position to the servo delay(step_delay); // wait } } // turn on the appropriate LED. if(pos == straight){ digitalWrite(straight_led, HIGH); } else { digitalWrite(divergent_led, HIGH); } } }// end of loop

Step 5: Step 5:Putting the Arduino, Servo and Breadboard Into the Vending Machine.

Once we had our code downloaded into the arduino and had all of our wiring done we started putting everything into the box. We also installed our window at this point.

Step 6: Step 6:Drop Box and Servo Installation

After we got our inside pieces painted. We installed our drop box that was going to hold our snickers.

Step 7: Step 7:Finishing Up

Once we had everything in place we secured it with clamps and glued everything one more time to make sure nothing was wrong. We always made a lot of tests dropping our snickers.

Step 8: Step 8: Finished Project

Once we go everything put in and the tests done that we needed we finished our project. Let us know how yours turns out!!



    • Creative Misuse Contest

      Creative Misuse Contest
    • Fix It! Contest

      Fix It! Contest
    • Water Contest

      Water Contest

    2 Discussions

    Excellent Vending machine design! Thanks for sharing!