Vending Machine Help

WBahn

Joined Mar 31, 2012
26,398
I would want the LED to switch off, and the money returned back. Then enter back to State 0.
The LED wouldn't have been ON!

Think about this.

You walk up to a machine that is in State 0, meaning that the LED is off, and put in a quarter. That takes it from State 0 to State 25. Nothing else happens. Then you put in another quarter. That takes it from State 25 to State 50. Now, according to the above, you want the LED to turn off (but it wasn't on) and you want it to return the money back to you and go back to State 0. How often would you visit a machine that behaved that way.

Perhaps the wisdom of smoking pot nonstop should be reconsidered. ;)
 

WBahn

Joined Mar 31, 2012
26,398
What qualifies as your "state table" depends on your author and your instructor. So this may or may not be adequate.

The way I like to organize a state table is by present state, so the present state is therefore the left-most column. Then you have the state-associated outputs next. Then you have the current inputs, followed by the event-associated outputs, and finally a column for the next state.
 

Thread Starter

smokingpotnonstop

Joined May 8, 2014
21
Is it legal to have present state as 00,01,10,11. Then for next state my inputs as 00(cancel), 01(soda button), 10(quarter). Then start finishing the table? So far, I've only see q1/q2 and input x =1 x=0 for my class work.
 

WBahn

Joined Mar 31, 2012
26,398
Listing both the name (even a couple letter mnemonic) as well as the state variable value is very useful, both in not messing up when creating the table and in not messing up when reading the table.
 
Top