Best way to show value of a variable in the IDE

Hi Guys, Kurte seems to be spot on with what you’ve noticed. I changed the 1 to a 0 and it works. so the state part works opposite to the BS2. Extremely grateful for everyones input. :smiley:

Way to go Kurt! http://www.unity.i8i.co.uk/forum/images/smiley_bowdown.gif

Kurt 1

Everyone else 0

While I have your attention heres another to keep you guys on your toes :wink:
Its a simple ir sensor that changes from logic 1 to 0 when object detected. IR led connected to P8 and VSS and sharp ir detector output connected to P9 and Vdd and VSS. resistors of correct ohms in series with P8 and P9.
I’m trying to read the output in the terminal window. Does the code below look ok? thanks.

irdetect VAR Bit
irdetect = P9

main:
FREQOUT 8,2,38500
input irdetect
serout s_out,i38400,[0]
serout s_out, i38400, [bin1 irdetect]
PAUSE 100

goto main

[code]irdet VAR Bit

main:
FREQOUT 8,2,38500
irdet = in12
serout s_out,i38400,[bin irdet,13]
PAUSE 100

goto main[/code]

Hi, Thanks for the code but not reading the sensor, its just giving me a 1 on a new line repeatedly. The circuit is definately working. I’ve tried a few variations but no success. I’ll keep trying, appreciate the help, dont want to be taking up everyones time.

I tested that code with the Bot Board II. I had to move the I/O to 12 to use the button / LED circuit. This is essentially the I/O pin with a 309 ohm pullup through an LED and a normally open switch to ground. It’s showing a 1 till the switch is closed then it’s 0. Not sure about what your IR detector circuit is outputting…

something is not quite right with that. taking the red wire to ground will charge the cap between the red and white wires. unless you have some other current source attached to the red wire the cap will remain charged as even leakage current through the photo transistor will keep it that way.
Perhaps you meant to take the red wire to +5V to discharge the cap, then change it to an input and wait for the it to go low?

Yes that’s what I intended to say. Taking the red wire to 5vdc will essentially place the 220 ohm resistor across the cap. Sorry… I was just going too fast.

I can get the same results using the bot board push button. But wont read the ir detector output. The circuit works as I’ve tried it with the BS2.

Please share the working BS2 code.

isn’t this his code?

LineSnsrPwr CON 10 ' line sensor power
LineSnsrIn CON 9 ' line sensor input
' ----- Variables ]------------------------------------------------------------
Sense VAR Word ' sensor raw reading
' ----- Main Code ]------------------------------------------------------------
Read_Sensor:

HIGH LineSnsrPwr ' activate sensor

HIGH LineSnsrIn ' discharge QTI cap

PAUSE 1

RCTIME LineSnsrIn, 1, Sense ' read sensor value

LOW LineSnsrPwr ' deactivate sensor

goto Display

Display:

debug [dec sense, 13]

PAUSE 100
GOTO Read_Sensor

working BS2 code is; thanks

irdetectleft VAR Bit

DO
FREQOUT 8,1,38500
irdetectleft = IN9

DEBUG HOME, "irdetecleft = ", BIN1 irdetectleft
PAUSE 100

LOOP

[code]irdetectleft VAR Bit

DO
FREQOUT 8,1,38500
irdetectleft = IN9

DEBUG HOME, "irdetecleft = ", BIN1 irdetectleft
PAUSE 100

LOOP[/code]
Thanks I learned the difference between the BS2 and BAP pin states are reversed.

I’m not sure what to tell ya. The Atom looks at anything above 2vdc as a high. It appears your IR LED may not be working the same on the Atom as it does on the BS2, although I can’t think of any logical reason why. If you have a volt meter it would be good to see what voltage is being developed on the I/O pin in both cases. What’s the difference?

What part is this? Is it an off the shelf sensor or something you made from scratch? Got a schematic?

I think this is what he is using.
parallax.com/StoreSearchResu … fault.aspx

wowy7 we got the issue with the RCtime code sorted yesterday.

As for a diagram for the ir detector its basically an IR led with pin8 connected in series with 1k resistor to IR anode and cathode to Vss.
Ir detector has leg 1 connected to Vdd , leg 2 connected to Vss and leg3 output connected in series with 220 ohm resistor and then to i/o pin9. I have made it myself but it has the exact same components as used by parrallax in an IR detector circuit. I will try add a circuit diagram tomor, and measure voltage drop.

Please post the measurements with the volt meter if possible. Do you protect the IR sensor from getting stray IR light directly from the side of the IR LED? The IR LED does emit some IR from the side. And the IR sensor can receive it if it’s a plastic molded package. This can make the sensor falsely detect objects when they are not there…