thangngoc
01-22-2010, 01:36 AM
I have a small alarm project that have to use basic stamp language to determine whether the input to the alarm is 5V or ground (0V) via pin 1. If the input is 5V then the result is logic 1 otherwise the result is logic 0 . How can I put them in basic stamp language?
there is a sample code input/output in the BS2. Not sure if this helps
' {$STAMP BS2}
' {$PBASIC 2.5}
' Program to control Don's cranberry bog pump
' Program watches two 24 volt inputs (reduced to 5 volts by the time it reaches the stamp)
' When both 24 volt inputs are on then the solid state relay will go on
' The solid state relay will stay on until both 24 volt inputs go off.
' Bog Pump 1.bs2
‘ Uncomment DEBUG statements to turn on debugging
check VAR Byte ' variable for debug output
DO ' Loop to watch the two 24 volt inputs
IF( IN3 = 1 AND IN1 = 1) THEN ' If both 24 volt inputs are on
HIGH 12 ' Turn solid state relay on
check = 1
'DEBUG DEC check ‘ Send condition state to terminal for debugging information
ELSEIF( IN3 = 0 AND IN1 = 0) THEN ' Only turn solid state relay off if both 24 volt inputs are off
check = 0
'DEBUG DEC check ‘ Send condition state to terminal for debugging information
LOW 12 ' Turn solid state relay off
'....................Debugging Code..............................
' This is useful if you have bad connections
ELSEIF( IN3 = 0 AND IN1 = 1) THEN ' These are just debugging lines to show
check = 2 ' what is happening on other 2 possible combinations of input ‘ ‘ line voltages
'DEBUG DEC check ‘ Send condition state to terminal for debugging information
ELSEIF( IN3 = 1 AND IN1 = 0) THEN
check = 3 ...
'DEBUG DEC check ‘ Send condition state to terminal for debugging information ...
ENDIF ' End the if then section
'..................End of Debugging Code.........................
LOOP ' Go back and look at the 24 volt inputs again
Post Edited (thangngoc) : 1/21/2010 7:06:51 PM GMT
there is a sample code input/output in the BS2. Not sure if this helps
' {$STAMP BS2}
' {$PBASIC 2.5}
' Program to control Don's cranberry bog pump
' Program watches two 24 volt inputs (reduced to 5 volts by the time it reaches the stamp)
' When both 24 volt inputs are on then the solid state relay will go on
' The solid state relay will stay on until both 24 volt inputs go off.
' Bog Pump 1.bs2
‘ Uncomment DEBUG statements to turn on debugging
check VAR Byte ' variable for debug output
DO ' Loop to watch the two 24 volt inputs
IF( IN3 = 1 AND IN1 = 1) THEN ' If both 24 volt inputs are on
HIGH 12 ' Turn solid state relay on
check = 1
'DEBUG DEC check ‘ Send condition state to terminal for debugging information
ELSEIF( IN3 = 0 AND IN1 = 0) THEN ' Only turn solid state relay off if both 24 volt inputs are off
check = 0
'DEBUG DEC check ‘ Send condition state to terminal for debugging information
LOW 12 ' Turn solid state relay off
'....................Debugging Code..............................
' This is useful if you have bad connections
ELSEIF( IN3 = 0 AND IN1 = 1) THEN ' These are just debugging lines to show
check = 2 ' what is happening on other 2 possible combinations of input ‘ ‘ line voltages
'DEBUG DEC check ‘ Send condition state to terminal for debugging information
ELSEIF( IN3 = 1 AND IN1 = 0) THEN
check = 3 ...
'DEBUG DEC check ‘ Send condition state to terminal for debugging information ...
ENDIF ' End the if then section
'..................End of Debugging Code.........................
LOOP ' Go back and look at the 24 volt inputs again
Post Edited (thangngoc) : 1/21/2010 7:06:51 PM GMT