Digital Detection Of Black And White With IR LED And Phototransistor

I have been using a simple Black/white detection circuit with my picaxe to make a line following robot.

i wired up a circuit like the one below and programmed the Picaxe with the code below.

basicly what it did was when the IR LED/Phototransistor pair detected black it sent the number 1 to my computer and when it saw white it sent the number 0. this worked fine with the circuit wired exactly like it is below, but when i changed the Picaxe input to a different pin it just kept constantly sending 0's to my computer.

any ideas why it isn't working on other pins?

IR_LED_Digital_Detection_Circuit.jpg

Code:

 

top:

if pinc.0 is on then

goto l

else

goto h

endif

goto top

 

l:

sertxd ("1")

sertxd (13,10)

pause 10

goto top

 

h:

sertxd ("0")

sertxd (13,10)

pause 10

goto top

I think its your code…

Since you changed the input pin on your picaxe I think you will have to change it from 0 to the new input pin in your code.

Hopefully that helps.

Yeah i did thatsorry for not

Yeah i did that

sorry for not making it clear!

I tested the analog input…

when it was sensing white it read about 8 to 9 and when sensing black it was about 25 to 40.

is this enough?

May be obvious but …

Have you checked that the circuit has not been knocked / open circuit on white side.  Is this assembled on PCB or just breadboard? Have you tested the current state of the analog input - you stated was as opposed to is.  I realize this is semantics but can lead to misunderstanding.  I would have thought a simple meter reading to check 0 is less than say a volt and 1 is above 3v would also be in order.