point counter
v_2hbran
Posts: 4
Still working on an arcade project for microprocessors.· We got a good kick in the right direction for making our coin counter work after a little bit of tinkering, but now we have to implement in some phototransitors· as sensors to count points.· The code we're using is a modified version we were using for the coin counter, but we aren't sure how to have it so its a time limit as well.· We'd like to have it go for about a min and we have each sensor for a different point value.·As well we don't know·how to get the total points to add up as they are achieved.·Here is what we have at this point:
' {$STAMP BS2}
' {$PBASIC 2.5}
IR_tripped_1·· PIN 0
IR_tripped_2·· PIN 3
IR_tripped_3·· PIN 6
sensor_1 CON 50
sensor_2 CON 75
sensor_3 CON 100
total VAR Word
·Restart:···· 'Come here on a restart (if required), to zero out Amount
total = 0
Main_Loop:
IF (IR_tripped_1 = 1) THEN
·SEROUT IN1, Baud19200,[noparse][[/noparse]"50 points."]
·total = total + sensor_1
·HIGH 12
·PAUSE 500
·LOW 12
·GOTO Check_Total
ELSEIF (IR_tripped_2 = 1) THEN
·SEROUT IN1, Baud19200, [noparse][[/noparse]"75 points."]
·total = total + sensor_2
·HIGH 12
·PAUSE 500
·LOW 12
·GOTO Check_Total
ELSEIF (IR_tripped_3 = 1) THEN
·SEROUT IN1, Baud19200, [noparse][[/noparse]"100 points."]
·total = total + sensor_3
·HIGH 12
·PAUSE 500
·LOW 12
ELSE
GOTO Main_Loop
ENDIF
Check_Total:
·PAUSE 1000
SEROUT IN1, Baud19200, [noparse][[/noparse]lcdcls]
SEROUT IN1, Baud19200, [noparse][[/noparse]" your score is:"]
PAUSE 3000
SEROUT IN1, Baud19200, [noparse][[/noparse]lcdcls]
Any help on where· we need to be going is appreciated!
' {$STAMP BS2}
' {$PBASIC 2.5}
IR_tripped_1·· PIN 0
IR_tripped_2·· PIN 3
IR_tripped_3·· PIN 6
sensor_1 CON 50
sensor_2 CON 75
sensor_3 CON 100
total VAR Word
·Restart:···· 'Come here on a restart (if required), to zero out Amount
total = 0
Main_Loop:
IF (IR_tripped_1 = 1) THEN
·SEROUT IN1, Baud19200,[noparse][[/noparse]"50 points."]
·total = total + sensor_1
·HIGH 12
·PAUSE 500
·LOW 12
·GOTO Check_Total
ELSEIF (IR_tripped_2 = 1) THEN
·SEROUT IN1, Baud19200, [noparse][[/noparse]"75 points."]
·total = total + sensor_2
·HIGH 12
·PAUSE 500
·LOW 12
·GOTO Check_Total
ELSEIF (IR_tripped_3 = 1) THEN
·SEROUT IN1, Baud19200, [noparse][[/noparse]"100 points."]
·total = total + sensor_3
·HIGH 12
·PAUSE 500
·LOW 12
ELSE
GOTO Main_Loop
ENDIF
Check_Total:
·PAUSE 1000
SEROUT IN1, Baud19200, [noparse][[/noparse]lcdcls]
SEROUT IN1, Baud19200, [noparse][[/noparse]" your score is:"]
PAUSE 3000
SEROUT IN1, Baud19200, [noparse][[/noparse]lcdcls]
Any help on where· we need to be going is appreciated!