Dear All,
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
Dear All,
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
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?
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.
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
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 "
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.
Well the coin acceptor was a mechnical action before, not sure if that is still 100% true though. I would image that both the bill and coin devices do the processing on board and use signaling to the vending machine logic.
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.
Example:
Good luck, friend.Code:switch(user.input) { case A_1: eject(PEPSI); break; case A_2: eject(SPRITE); break; case A_3: eject(DR_PEPPER); break; // etc. }
(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).
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