need help with basic stamp code
thangngoc
Posts: 23
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
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
Comments
If you need a simpler version, then you can simplify what you've already posted. If you want us to rewrite the program for you, I don't think so.
What you said you want to do is very simple. You need to go through the tutorials for learning about the Stamp and Parallax Basic. These are "What's a Microcontroller?" and the "BASIC Stamp Syntax and Reference Manual".
www.parallax.com/tabid/477/Default.aspx
Look under "BASIC Stamp Documentation" and under "Stamps in Class Downloads".
' {$STAMP BS2}
' {$PBASIC 2.5}
INPUT 1 ' Make P1 an input
Main:
DEBUG "State of Pin 1: ",
BIN1 IN1, CR
goto main
END
' Do it 1000 times
' {$STAMP BS2}
' {$PBASIC 2.5}
I VAR WORD
Main:
INPUT 1 ' Make P1 an input
FOR I=1 to 1000
DEBUG "State of Pin 1: ",
BIN1 IN1, CR
NEXT
END