View Full Version : Trying to get started using BS2P40

04-15-2007, 08:10 AM
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.

Chris Savage
04-15-2007, 08:53 AM

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

04-15-2007, 10:38 AM
CON is a constant.
VAR is a variable.
Take a look at this, it should help www.parallax.com/dl/docs/books/edu/Wamv2_2.pdf (http://www.parallax.com/dl/docs/books/edu/Wamv2_2.pdf)

- Stephen

04-15-2007, 10:48 AM
HI, programming takes a while to learn and the best way to learn is by doing. A good place to start , if you don't already have it , is Whats a Microcontroller http://www.parallax.com/detail.asp?product_id=28123 its free to download and is full of examples for you to work through.

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

DEBUG "How much was lunch?",CR
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 http://forums.parallax.com/images/smilies/tongue.gif

Jeff T.

04-17-2007, 07:45 AM
I have been reading everyones advice and it is helping.· The program is starting to come together somewhat.· As always there is so much to learn and such little time.

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, ["Hello, this text will wrap."]

My dip is set to On 1 Off 2