![]() |
| | #1 |
| Registered User Join Date: Apr 2008
Posts: 83
| Vending Machine Logic? I am designing code for Vending Machine..could anybody know the logic or just give me links where i will find the logic?? thanks in Advance |
| shwetha_siddu is offline | |
| | #2 |
| Woof, woof! Join Date: Mar 2007 Location: Australia
Posts: 3,139
| Other than general knowledge and intuition what is there to know? You put in $, you select an item, the item is despensed and you get your change back. Have you never used a vending machine in your life? |
| zacs7 is offline | |
| | #3 |
| Wheres the lesbians? Join Date: Oct 2006 Location: UK
Posts: 1,219
| If its got those curly thing that the food comes out of you want to make sure that they don't rotate too much so that they drop two thin items in one go. You also need to make sure that they drop one item - packets of crisps often get stuck. Maybe you could use lasers to scan how fat the object is and rotate accordingly. That would rule. |
| mike_g is offline | |
| | #4 |
| Registered User Join Date: Nov 2007
Posts: 171
| It's fairly straightforward. Here's some pseudo code: Code: if (someone puts money into the machine)
{
prompt snack selection
make sure snack is not dispensed
if (the person hits the money return button)
do nothing
}
__________________ I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo |
| NeonBlack is offline | |
| | #5 |
| Registered User Join Date: Apr 2006 Location: United States
Posts: 3,201
| |
| whiteflags is offline | |
| | #6 |
| verbose cat Join Date: Jun 2003
Posts: 209
| It ate your money, too? You'll just have to fill out one of those little refund cards. Now where are they...?
__________________ abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments " |
| jEssYcAt is offline | |
| | #7 |
| Super Moderator Join Date: Aug 2001
Posts: 7,470
| A vending machine would have a significant amount of code to deal with the DBA (dollar bill acceptor), the coin acceptor, the button inputs, and the machinery to actually dispense the product. I would say there is a hefty amount of device code involved. |
| Bubba is offline | |
| | #8 | |
| & the hat of GPL slaying Join Date: Sep 2001
Posts: 5,730
| Quote:
Buttons mainly just have to be debounced and for dispensing it merely requires turning a motor (for screw based ones) or opening a latch (for drop ones like soda machines). Vending machines are used as examples a lot when dealing with Finite State Machines and the core logic really isn't that difficult. It really comes down to keeping track of how much money has been deposited and then when a selection is made seeing if enough money has been deposited. | |
| Thantos is offline | |
| | #9 |
| Banned Join Date: Aug 2001 Location: Visalia, CA, USA
Posts: 3,699
| Example: Code: switch(user.input)
{
case A_1:
eject(PEPSI);
break;
case A_2:
eject(SPRITE);
break;
case A_3:
eject(DR_PEPPER);
break;
// etc.
}
|
| master5001 is offline | |
| | #10 |
| Banned Join Date: Aug 2001 Location: Visalia, CA, USA
Posts: 3,699
| (I would also like to put my $5 on the fact that this is a homework and this gentleman was not hired to write the logic for someone's machine). |
| master5001 is offline | |
| | #11 |
| Registered User Join Date: Apr 2009
Posts: 1
| Not really, but i can give you some tips in finding some logic about your programming project well why not to try to search in some open source site about programming i think you can get their some little information about your problem... _________________ Vending Machine |
| blue.machine is offline | |
![]() |
| Tags |
| crisps, mmmm |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| School Mini-Project on C/C++ (Need Your Help).. | EazTerence | C++ Programming | 4 | 09-08-2005 01:08 AM |
| Porting from 32 bit machine to 64 bit machine! | anoopks | C Programming | 10 | 02-25-2005 08:02 PM |
| Wanna test vending machine | Roaring_Tiger | Tech Board | 6 | 08-25-2004 05:51 PM |
| Vending machine | Unregistered | C++ Programming | 6 | 06-13-2002 10:21 PM |