Pages: [1] 2   Go Down
Author Topic: Arduino vending machine project  (Read 4643 times)
0 Members and 1 Guest are viewing this topic.
NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

    I plan to use an old lenovo computer as a secure housing and gut it(done). I drilled a hole in the front where the power button is and I plan to put a pinhole camera there. I'll use the two LEDs on the front for status indicators(HD activity LED for out of stock warning and power LED for power. Then I'll melt a slot through the plastic big enough for a quarter (done). I then cut a hole through the mesh behind  the plastic front and made a wood chute for the coin to roll down. The chute stops on the other side of the mesh.That's as far as I got.
   
     I plan to have another wood chute go from the hole in the metal to a coin sorter. Then I will modify the quarter section of the coin sorter. I will run a wood chute from there with a coin switch at the end of the chute. The quarter will then drop into a metal box. The coin switch will be connected to a 5 volt power supply on one end. On the other end of the coin switch, a wire will run to the arduino.

      This is the part I need help with. I need to know which pin the wire for the switch should go into and I need help designing a sketch for the arduino. What I need is a program the states: If 5v is received on pin x, run the motor on pin y for x amount of seconds. Since I want to charge 75 cents a drink, it needs to take 3 switch activations to dispense a soda. I plan to do this by timing how long it takes to dispense a soda and dividing it by 3 and putting that quotient into the program.

    Now for the soda dispensing mechanism. Two bike chains with hooks welded on them. Each side will be tightened by 2 sprockets with axles going over to the opposite side. Then I'll have two U brackets to tighten the axles. I'll bolt one to the roof and one to the ground. I'll screw the motor into a bracket and weld it to the center of one of the sprockets.After someone puts three quarters in, the motor will turn the chain to a point where one of the hooks will flip and the soda will come rolling down the ramp.

      I will then find AC adapters to power the arduino and camera. I'll plug those into a power strip and then run that cable out the back of the housing. For the LEDs on the front I'll replace the LED on the Arduino with the one on the front of the housing(I'm using an Arduino on a breadboard). For the out of stock LED I'll glue a piece of wood onto the last hook on the chain. Then I'll glue a normally closed tact switch( When you push the switch, it breaks the circuit) onto the piece of wood. Next I'll solder two wires to the tact switch and put to female wire connector on each end. Then I'll put a male wire connector on two long pieces of wire. I will then zip tie the wires to the top of the housing with enough slack for the  for the chain to complete revolutions. Then I will connect the male connector to the female connector on both wires.

      Next I will connect one of the zip tied wires to the positive wire on the last LED. Then I will connect the the other zip tied wire to the positive wire on a 2 volt AC adapter. I will connect the negative wire on the LED to the negative wire on the AC adapter. I will plug the AC adapter in to the power strip. Then I will plug the power strip into the wall, load it with sodas, close and lock the door and start collecting money!
It will be greatly appreciated if someone helps me with the sketch and points out any potential flaws.
             Thanks in advance,
                   Cmeacham98
« Last Edit: March 28, 2011, 04:42:11 pm by cmeacham98 » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 524
Posts: 26438
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like an interesting project.
What is the camera for?
You can find motors & power supplies here www.mpja.com
You will need some relays or MOSFETs to control power going to the motors.
Instead of a tact switch, a microswitch, the kind that has an arm on it, may be easier to mount and adjust.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

THanks for the info. And the camera is for people who try to cheat or vandalize the machine.
Logged

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone know of a sketch that could achieve what I want?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25770
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know about a sketch, but maybe some paragraph breaks in the description of the problem might encourage me to read it.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm assuming you're thinking of a sketch like a drawing. I mean the arduino sketch like a program.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25770
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm assuming you're thinking of a sketch like a drawing
I know what an Arduino sketch is, I just can't read the statement of the problem.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok I will fix it.
Logged

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is fixed.
Logged

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I  probably have to run a wire from the 5v rail of the breadboard to the switch and then back to an analog pin on the arduinio, right?
Logged

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I kind of have this figured out. I need to run a wire from the 5v rail to an analog input pin on the arduino. Then I need to have a wire from another analog pin to a MOSFET gate pin. Connect the + terminal of the 12v power supply to the MOSFET source pin. The connect a cable to the drain pin of the MOSFET to the motor. Then wire the - terminals together. Now the only thing left is the sketch. Where should I start? 
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 524
Posts: 26438
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Your last post addresses a motor driver.
This is the circuit you want for that, using an N channel logic level MOSFET.  The MOSFET will turn the motor on when the arduino pin it is connected to is high (can be any of the pins, with digitalWrite (pinX, HIGH); to turn it on & digitalWrite(pinX, LOW); to turn it off.
The second diagram shows typical ways of connecting switches & LEDs to receive inputs & have user indicators.
There are plenty of tutorials available that show the bacics of a sketch, do a  little reading & try one, then post again with questions.


Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the diagrams. I have  plans to build an arduino from http://www.instructables.com/id/Build-Your-Own-Arduino/
Logged

NJ
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I finished the sketch. Here it is:
------------------------------------------------------------
/*
Arduino vending machine program
 */

int mosfetPin = 8;
int coinPin = 7;
int val;


void setup() {               
  pinMode(mosfetPin, OUTPUT);     // Set mode of pin to output
  pinMode(coinPin, INPUT);     // Set mode of pin to input
}


void loop() {
  val = digitalRead(coinPin);  // Read input value and store it in val
  if (val == LOW) {  // Check if the coin hit the microswitch
  digitalWrite(mosfetPin, HIGH);   // Activate the mosfet gate
  delay(5000);              // Allow the motor to run enough to complete task
  digitalWrite(mosfetPin, LOW);    // Stop motor
  }
}
-------------------------------------------------------------
Please check out my sketch and try to point out any flaws.
« Last Edit: March 31, 2011, 12:52:45 pm by cmeacham98 » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25770
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
digitalWrite(8, LOW);   
You defined a nice name for pin 8 - why not use it?

(it may also help if you redefine the nice name as a "const")
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1] 2   Go Up
Jump to: