PDA

View Full Version : Output - Input



Mike only
01-18-2007, 11:09 AM
Halo,
I'm new in PBasic programming and tried to make a program with BOE (BS2). This time, I'm using· INPUT and OUTPUT commads, but I've different result, when I put the INPUT command in front of OUTPUT command:

OUTPUT 8
OUTPUT 9
INPUT 10

Main:
···· OUT8=IN10
····· OUT9=IN10
GOTO Main

Is different result when I make a program as below:

OUTPUT 8
OUTPUT 9
INPUT 10

Main:
···· IN10=OUT8
···· ·IN10=OUT9
GOTO Main

Is it correct that I may not freely put the commands as I will, even though it's logically·the samehttp://forums.parallax.com/images/smilies/confused.gif
Sorry for my poor english.

Thank you
Mike only

Mike Green
01-18-2007, 11:33 AM
These are not logically the same. The "=" operation is an assignment in PBasic, not the mathematical equivalence (equality).
It is a little confusing since the same character is used to test for equality in the IF statement (but only in the IF statement
or the WHILE or UNTIL portions of the DO statement).

When you say "OUT8=IN10", you are saying "make the output pin 8 the same as the present value of input pin 10".
When you say "OUT9=IN10", you are saying "make the output pin 9 the same as the present value of input pin 10".

When you say "IN10=OUT8", you are actually doing something unusual since you are trying to set an input register bit
to the value of an output register bit. The PBasic interpreter promptly ignores what you have tried to do and sets IN10
to the actual value of the input pin. You can use OUT8 as a value since the output register contains the last value that
you set for the output pin even if the direction of the pin is set to input.

I hope this helps.

Mike only
01-18-2007, 01:00 PM
Thank you very much for your informationhttp://forums.parallax.com/images/smilies/smile.gif

Best Regards,

Mike only