Mini vending machine: here's what im doing... please help!
hmiller
Posts: 17
Hi,
I've been wanting to build a miniature vending machine to stick on my counter that dispensed
small candy bars. I have gotten the servo length and pushbutton right but now I can't seem to figure out how to get the display to show the text "vending..." and "thank you!". I made the positioning right and have it all good to go but i cant get the sequence for "vending..." to align with the servo correctly. please help!
Here's my code so far:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG ? IN1
counter VAR Word
' press button to start vend
IF IN1 = 0 THEN
DEBUG "Vending...", CR
' display "vending..."
HIGH 15
SEROUT 15, 84, [17, 22]
SEROUT 15, 84, [" vending..."]
' start vend
FOR counter = 1 TO 50
PULSOUT 2, 1000
PAUSE 20
NEXT
' display "thank you"
HIGH 15
SEROUT 15, 84, [17, 22]
SEROUT 15,84, [" Thank you!"]
PAUSE 5000
SEROUT 15, 84, [12]
DEBUG "Thank you!", CR
' clear display
SEROUT 15, 84, [12]
ENDIF
Thanks in advance!
I've been wanting to build a miniature vending machine to stick on my counter that dispensed
small candy bars. I have gotten the servo length and pushbutton right but now I can't seem to figure out how to get the display to show the text "vending..." and "thank you!". I made the positioning right and have it all good to go but i cant get the sequence for "vending..." to align with the servo correctly. please help!
Here's my code so far:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG ? IN1
counter VAR Word
' press button to start vend
IF IN1 = 0 THEN
DEBUG "Vending...", CR
' display "vending..."
HIGH 15
SEROUT 15, 84, [17, 22]
SEROUT 15, 84, [" vending..."]
' start vend
FOR counter = 1 TO 50
PULSOUT 2, 1000
PAUSE 20
NEXT
' display "thank you"
HIGH 15
SEROUT 15, 84, [17, 22]
SEROUT 15,84, [" Thank you!"]
PAUSE 5000
SEROUT 15, 84, [12]
DEBUG "Thank you!", CR
' clear display
SEROUT 15, 84, [12]
ENDIF
Thanks in advance!
Comments
A serial LCD? Whose? Is it set up for 9600?
What's all this then?
There's no reason (in programming) that it should go out.
Maybe your servo knocks out 5V to the LCD, when it starts up it makes the 5V (Vdd) sag?
What happens if you disconnect the servo and run the program?
Are you using a BoE?
Are you running your LCD out of one of the BoE servo ports?
http://forums.parallax.com/showthread.php?133376-Parallax-2x16-Serial-LCD-(Non-Backlit)-suddenly-stopped-working
I don't see anything in your program to account for that.
An "8V power adapter" doesn't mean a lot without a current specification to go with it.
If you have a voltmeter then place it on the 5V at the LCD connector and see what happens there.
Are you using a Board of Education or what?
Just the LCD stuff --
FOR counter = 1 TO 50
PULSOUT 2, 1000
PAUSE 20
NEXT
It still didnt want to display "vending..." even with the servo not running, and what are the two boxes of code you listed above?
The voltage regulator on the newer models can only provide a max of about 500mA, and the older models only about 50mA, so this may be your problem.
It can probably run the LCD, but only with the backlight off.
Try that.
After the line of code:
SEROUT 15, 84, [" vending..."]
I added this line of code:
SEROUT 15, 84, [12]
Which obviously clears the display, so I took out "SEROUT 15, 84, [12]"... I click the run button in the parrallax basic stamp editor to lauch the new code to the stamp. It runs like it should. It displays the the "vending..." WITH BACKLIGHT WHILE SERVO IS RUNNING, but when I go to click my button on the vending machine it just runs the servo and says "Thank you!" but doesn't display vending like it did right when I launched it. WHAT IS GOING ON?!?!