Vending Machine Designed By: Austin Saunders

advertisement
Vending Machine
Designed By: Austin Saunders
Physical Setup:
- Actobotics parts and foam board for frame
- Coat hangers for coils
Front View
Back View
Circuit Diagram
Software
Functions
DelayuSec – Delays for a specified number of microseconds
getKey – Waits for a key to be pressed and outputs an integer corresponding to the key
writeNibbleToLCD – Writes a nibble to the LCD screen
writeByteToLCD – Calls writeNibbleToLCD twice, thus writing a full byte
printLCD – Calls writeByteToLCD and causes characters to be displayed on the LCD
InitializeLCD – Performs a standard initialization sequence on the LCD
rotate – Causes one of the stepper motors to rotate based on which key was pressed
empty – Notifies the user that the desired row is emty and prevents the corresponding motor from rotating
main – Pseudocode shown on next page
Pseudocode (Main Function)
Initialize LCD
Initialize Port T, pins 0,2,4 for output
Initialize Port M, pins 0-3 for output
Set up A/D ports for i/o
Initialize Port AD, pins 0-6 for output
While(true)
set variable key equal to getKey()
print “Enter a Valid Key” on the LCD
if(key 1 is pressed and row 1 isn’t empty)
rotate motor 1 360 degrees
if(key 2 is pressed and row 2 isn’t empty)
rotate motor 2 360 degrees
if(key 1 is pressed and row 1 is empty)
print “Row 1 is empty” on LCD
if(key 2 is pressed and row 2 is empty)
print “Row 2 is empty” on LCD
if(key * is pressed)
print “Restock the Machine
1=Restock Complete
2=Cancel”
on LCD
if(key 1 is pressed)
reset count variables to 0
exit this loop
if(key 2 is pressed)
exit this loop
Timing
QUESTIONS?
Download