Hi Lindy, > No! No matter where I pointed the thing, the IR detector detected it. > I even put aluminum foil around the IR detector, and still it wouldn't > fail It is just a Gr=FCndig TV and remote. > > What am I doing or thinking wrong? > I even put aluminum foil around the IR detector and still it wouldn't f= ail. Use something black. Tin foil is like placing tiny mirrors all around you= r IR detector. One small opening, crack, etc, and the IR signal will bounce ar= ound inside the foil striking the IR detector face. The TSOP brand are real se= nsitive and hard to block. Especially in a highly reflective environment. Be sure to cover the sides, back, bottom, top, etc,, Small amounts of IR = energy can pass through the IR detector plastic case, so just blocking the front= may not always do the trick. Black elctrical tape covering all sides with a small= hole just over the IR module dome face works to make it very directional. I assume you're just using the TV transmitter for testing your initial IR= detection code? You can't really control the TV transmitters output unless you modi= fy the transmitter or partially cover/block the output window. If you're goal is to have the PIC control the IRLED on your bot, you can = place a piece of black heat shrink over the IRLED to make the beam more direction= al. WIth the PIC driving your IRLED you can control the output power by adjus= ting the PWM duty cycle. A PIC with hardware PWM would be handy, but you can creat= e simple code to drive the IRLED at the band-pass frequency of your IR dete= ctor module something like this; Variable "Cycles" contains the number 40kHz cycles the routine will gener= ate. ; Note: Assumes 4MHz osc & you're using RA.7 to drive the IRLED. Pulse ;// IRLED 680 bsf porta, 7 ;// 1uS, LED=3Don RA.7----|>|---------/\/\/\/\/---= ---- gnd goto $+1 ;// 3uS goto $+1 ;// 5uS goto $+1 ;// 7uS goto $+1 ;// 9uS goto $+1 ;// 11uS goto $+1 ;// 13uS bcf porta, 7 ;// 14uS, LED=3Doff goto $+1 ;// 16uS goto $+1 ;// 18uS goto $+1 ;// 20uS goto $+1 ;// 22uS decfsz Cycles,F ;// 23uS goto _Pulse ;// 25us =3D 40kHz The IR detectors output will not return the the idle state for a brief pe= riod, and the PIC is plenty fast enough to sample the output before it settles. Just sample= the detector output immediately on exit from the pulse routine. Another approach could use two variables. One holds the high time, one ho= lds the low time, and you have control of the carrier duty cycle. Here's one project I did using hardware PWM for IR distance measurement w= ith CDS light readings to adjust the IRLED output power. It's very simple, but it= does work, and you can't beat the price..;o] http://www.rentron.com/PicBasic/infrared_object_detection.htm We have several robot projects online http://www.rentron.com/Micro-Bot/in= dex.htm with IR detection, sonar, etc,, you may find helpful. The code is in PicBasic Pro= , but the theory is still the same in .asm, C or BASIC. I've done a few high-speed IR comm links, an IR BASIC Stamp programming s= ystem, and a few more gadgets, so if you get stuck on the IR thing let me know. Be gla= d to offer any help I can. > I tried to move from IR to sonar, but I cannot understand how the elect= ronic portion works > for the receiver Take a peek at this: http://www.robot-electronics.co.uk/htm/srf1.shtml Fu= ll schematics & source code for the http://www.robot-electronics.co.uk SRF04 sonar range = finder. You can buy the SRF04 sonar range finder pre-assembled too. I have code i= n PicBasic Pro & CCS C for the SRF04 if you would like copies. Regards, -Bruce tech@rentron.com http://www.rentron.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics