Trying to get started using BS2P40
wrathofskidog1987
Posts: 3
I need help getting· my code started for BS2P40
So far I have:
INPUT 2:· 'Input from a sensor.· Sensor will sense a high (4.15Volts),
··············'and for a low (0 Volts)
OUTPUT 0: 'Output to valve.· When Input 2: senses a low (0 Volts),
············· ' this will be the queue to OUTPUT 0: to go high (5 Volts), ie··
············· 'turn·on.· If·INPUT 2: is high (4.15Volts) then OUTPUT 0: will do·
············· 'nothing.
As a newbie I have been messing around with While loops trying to figure them
out in order to control my project accordingly.· I have looked at some sample programs and they seem to declare CON and VAR's.· Trying to get my hands around them (CON and VAR's) to see if I can use them· to help.
So far I have:
INPUT 2:· 'Input from a sensor.· Sensor will sense a high (4.15Volts),
··············'and for a low (0 Volts)
OUTPUT 0: 'Output to valve.· When Input 2: senses a low (0 Volts),
············· ' this will be the queue to OUTPUT 0: to go high (5 Volts), ie··
············· 'turn·on.· If·INPUT 2: is high (4.15Volts) then OUTPUT 0: will do·
············· 'nothing.
As a newbie I have been messing around with While loops trying to figure them
out in order to control my project accordingly.· I have looked at some sample programs and they seem to declare CON and VAR's.· Trying to get my hands around them (CON and VAR's) to see if I can use them· to help.
Comments
Making P0 and output may not do anything for you other than make the pin an output. The default state of the pin will be LOW. Perhaps you want to do HIGH 0 instead?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
VAR is a variable.
Take a look at this, it should help www.parallax.com/dl/docs/books/edu/Wamv2_2.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
The programming interface you use to download programs to your Stamp has a help file describing in detail commands , memory organisation , logical operators and more. Refer to it often, whenever you have a problem to solve look at the commands and see if there is one that fits the situation.
Regarding constants and variables, when manipulating numbers and data in a program its good practice to give the data a name that relates to what it is.·A constants value never changes during the running of your program whereas·the value of a·variable can change as often as you want. Heres a small example where you spend the same on gas each day so the daily expenditure on gas is a "constant" , you buy lunch but the price varies so the price is a "variable" your daily expenditure is also "variable"
Gas CON 3
Lunch VAR Byte
Expenditure VAR Byte
main:
DEBUG "How much was lunch?",CR
DEBUGIN DEC2 Lunch
DEBUG CR
Expenditure=Lunch+Gas
DEBUG DEC? Expenditure
GOTO main
If gas goes up all you have to do is change its constant value once to change it throughout the program and you dont have to have a byte for lunch but thats another story
Jeff T.
I am playing around with my #555-28027 PIR Sensor Module and #27977 2x16 Serial LCD, and hoping to integrate them into my circuit this week and then into my code.
The tough part for me is to integrate it all together.· My sample code needs to be brought together into a single program yet.· I am trying to follow the PBasic style points as well....
My #27977 2x16 Serial LCD is not working I typed in the sample code that comes with it ie
TxPin Con 7
Baud2400 Con 32
HIGH TxPin················ 'Set pin high to be a serial port
PAUSE·100················ 'Pause for Serial LCD to initialize
SEROUT TxPin,· Baud2400, [noparse][[/noparse]"Hello, this text will wrap."]
My dip is set to On 1 Off 2