"reading" input pin status question

Hola todos
I’ve got a simple question here.
I have the Tracker Ver 3.0 line tracking sensor from lynxmotion. I have it plugged to pins 13,14 and 15 on my Bot Board II.
I’m trying to read the input from the sensor using debug but it simply doesn’t work.
the program i wrote is:

input p13
input p14
input p15
main
debug [bin p15]
goto main

I’m just trying to know if the pin gets a “1” or a “0” from the sensor but using what i wrote, the debug gives me “1111” which is binary for 15.
Also, I tried putting an if statement such as:

if p15 = 1 then
servo p4,500

no matter what the sensor “sees” the program never enters the if condition.
I need help boys and gals. THX

c’mon guys. I’m really stuck.
To simplify my question, How do I read the voltage level of any of the pins on the Bot Board II? something like the ADin command, just applicable to the rest of the I/O pins??? :cry: :cry:

Taking a quick look at the online manual it looks like you should be able to get the status with the standard input stuff like you have.

Have you verified that the sensor is working correctly? Moved it over a black line and see if the LEDS go on or off… Assuming you have.

What you might want to try next is not to test for 1, but instead test for not being zero.

like:
if p15 <> 0 then
servo p4,500

Just a thought

Kurt

Hi kurt
the problem is that when i use debug, the value i get for p15 is 15, not 1 or 0.
The sensor works fine. I moved it to the analog I/O and used ADin and recieved good results (numbers between 2 and 1023) so the problem must be me not knowing how to “read” an I/O voltage levels.
Why do I get a value of 15 for P15, a value of 14 for P14 etc…???
I need the analog pins for different sensors so I have to figure this out.
Any hints??? :cry:

I don’t think it would make a difference, but instead of p15, you might try in15.

Not knowing what processor you have plugged into your BB2. If it is an atom Pro, you have 8 analog IO pins. (you can use P16-P19).

Do you get a 0 when you expect it? Many times a TRUE value is anything but zero. Also many of the IO modifiers like BIN have a tendancy to sign extend the result size up. For example in the program I currently am debugging, I have a word value with a hex value of lets say FFFE, but when I output it to the debug terminal: serout S_OUT, [hex iError]
It shows up as FFFFFFFE. Not sure if you are hitting this same condition.

If you really want 1 or 0, you could probably try something like:

LTLeft var bit
LTCenter var bit
LTRight var bit

LTLeft = IN13
LTCenter = IN14
LTRight = IN15

if  LTRight then
    or 
if LTRight = 1 then
...

Not sure if that will help, but at least it will give you a few things to try…
Kurt

I was just thinking the same thing kurte, on the BAP I use something like

MyPin var bit ; define a bit sized variable

MyPin = IN7 ; read the state of the pin

Yes that’s it. Reading inputs is one thing that can be difficult with atoms at first. If you look in the manual;

Hardware, Memory, Variables, Constants
Variables
Pin Variables (ports)

you will find…
State
IN# or OUT# 1 bit P#
(where # is a number from 0-31)

Soooo
EddieB is exactly right in his description of how to read the status of an I/O pin.

…That little bit of poetry “IN#” does work.
Thanks everybody!!! :smiley: