Since (according to your 1st post) you want to end up with some sort of IR communication, I'd suggest getting rid of that phototransistor and getting an IR receiver module as dhouston suggested earlier.
If you do a search on 'GP1U' at www.digikey.com, you'll get a bunch of hits for various IR detectors.
The GP1UM261RK (which just happens to be the one that I use for a lot of my projects and it works very well) is sensitive to IR modulated at 38Khz.
At the transmitter end, I use a 555 timer tuned to 38Khz @ 50% duty cycle (actually nowadays I'm using a 10F200 for the same function and it's more accurate). I run the output of that to an input of an AND gate, the other input of that same AND gate goes to a serial output pin on the PIC. The output of the AND gate (which is the 38Khz carrier, switched on and off by the PIC), goes to the IR LED unit (which is usually either one IR LED or a few IR LEDs switched by a MOSFET).
At the receiver end, I have the above mentioned IR detector unit hooked up. The output has a 1K pullup on it, and is connected to a PIC pin used for serial input.
According to the datasheets, this detector takes about 8 cycles of 38Khz to lock on (.21ms), so baud rate is limited by the carrier frequency. In the very best of circumstances, the highest baud rate you'll achieve is 1200 baud. I use 300 baud when I need to 'move' data, and usually stick with something around 100 baud if I'm just switching something on or off.
This is the code I use in my MP3 player that I built. I used an old Pioneer sound system remote control to run it:
Code:
'IR sensor - Digikey Part # 425-1147-ND, GP1UM281QK, 38KHz,
'side mount, 2 22uF tantalum cap's paralleled across
'power/ground, 47ohm resistor in series between power source and power pin
'PIC18F4620 @ 40Mhz, pulsin will change according to oscillator frequency
remotecheck:
irdata1 = 0 : pulsin irbit , 0 , temp1w
if ( temp1w > 1200 ) then
if ( temp1w < 3300 ) then 'header pulse is about 2.2ms, check for
'a pulse a bit longer than a binary 1, but
'shorter than 1 1/2 header pulses
getnextpulse1:
for temp1 = 0 to 11
pulsin irbit , 0 , temp1w : orbits = 0
if temp1w < 275 then orbits = 1
if temp1w > 1650 then orbits = 1
if orbits = 1 then
goto remotecheck
else
if temp1w < 825 then irdata1.0[temp1] = 0
'Sony IR Remote Signals - Unit, T=550us,
'Header = 4T Pulse followed by 1T space,
'Binary 0 = 1T Pulse followed by 1T space
'Binary 1 = 2T Pulse followed by 1T space
if temp1w > 825 then irdata1.0[temp1] = 1
endif
next temp1
'irdata1 has any data received and decoded by ir detector, 12 bit sony code
endif
endif
Bookmarks