Setting up variables
johntech
Posts: 8
I have 5 IR detectors that I am monitoring. I am using a BS2 and using pins 1 - 5 as input pins.
When they are not blocked all the inputs are low (0), when blocked they are high (1)
Right now I am using a ·IF/THEN·tree to see which one(ones)·is (are)·blocked.
I am reading the Basic Stamp Syntax and Reference Manual
I am wondering·how to set a variable ex:
IRBlocked· var nib
then read the 5·inputs as· either 1's or 0's· ex: 00000 - 11111 or any combination between in the group
and then use a select case statement to display which ones are blocked depending on the state of the
5 digits.
So if the first one was blocked IRBlocked would equal "10000"
The last two blocked would equal "00011"
Any help would be appreciated
Thank you
John
When they are not blocked all the inputs are low (0), when blocked they are high (1)
Right now I am using a ·IF/THEN·tree to see which one(ones)·is (are)·blocked.
I am reading the Basic Stamp Syntax and Reference Manual
I am wondering·how to set a variable ex:
IRBlocked· var nib
then read the 5·inputs as· either 1's or 0's· ex: 00000 - 11111 or any combination between in the group
and then use a select case statement to display which ones are blocked depending on the state of the
5 digits.
So if the first one was blocked IRBlocked would equal "10000"
The last two blocked would equal "00011"
Any help would be appreciated
Thank you
John
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I guess I need to do some more reading on the ina and inb commands and differences between NIB and the BYTE
Thank you Tracy for the code.
I'll try your code and read up on the commands in your line
····· myIR = inL >>1 & %00011111
If I am looking for a certain state of the IR's· say "11011"
then I can use a simple IF/THEN statement·like
IF myIR = "11011" THEN OUT 10
I'll have to try that and see if it works
Thanks again to both of you
John
IF myIR=%11011 THEN HIGH 10
It only becomes a string for display PBASIC when formated by the BIN5 myIR modifier. PBASIC does not have string operators or string variables.
OUT 10 is not a valid syntax. You can say,
OUTPUT 10 ' makes p10 an output
OUT10=10 ' makes p10 high
or
HIGH 10 ' makes it output and high all at once.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
It's back to the book for more reading
Thank you Tracy
John