'IRDEMO.BAS .For Picaxe 18A/X with a SONY IR remote. Ver 1.0 Stan. SWAN 23 Nov. 2003 'This may appear as yet another article in Australian monthly "Silicon Chip" early 2004 'Use sertxd & F8 (@4800 bps)for 18X or serout etc 18A/X to find unexpected infra codes 'Sony TV/VCR unit here gave Vol+/- =12/15 ,Prog +/- =10/13 ,On/Stnby=17,& 0 button =11 'Rev.Ed's ($A39) AXE040 IR Remote pix/.pdf data indicates 17 infrain codes can be read 'IR sensor (~$6 Jaycar ZD1952 )runs OK 4.5V but suspect below 4V. Remove 330 Ohm ? 'This sensor has inbuilt detector,limiter,B.P.F,demodulator,integrator,comparator.Phew! '3xAA (4.5V)circuit drain ~2mA 18A/X + ~3mA IR sensor. Each LED draws ~ 20mA of course. 'Control ranges ~5m, but since IR wavelength ~800-1000nm & behaves like light, salvage 'a converging lens from a disposable camera to extend range,although tighter direction. 'Build the Picaxe & sensor into a cheap solar powered garden lamp that's been beefed up 'with a LED cluster? Brighter lamp could just be on as needed rather than dim all night 'N.B. generating suitable IR codes much harder since no Picaxe works @ 40kHz of course. 'Normal PICs can do so ( but difficult assembler coding !),& even some scope for 555s? 'Basic Stamp PBASIC *button* command works as pseudo interupt here.Needs more insights 'PICNIK box layout =>www.picaxe.orcon.net.nz/irdemo.jpg & Rev.Ed forum =>www.picaxe.com '-------------------------------------------------------------------------------------- IRDEMO: b0=0 ' routine to show IR control with white LED 1,Red 2,piezo 7 infrain ' 18A/X command to read IR remote & put this value as "infra" let b0= infra ' assign the infrared code value to a normal variable sertxd(#b0,13,10) ' F8 display +CR/LF. N.B- SERTXD 18X only.Use serout etc 18A/X pause 200 ' Remote control switch 'debouncer'.Alter to suit-maybe button? if infra= 1 then WLEDON ' Several effects can be on at once as written.N.B Don't if infra =2 then LEDSOFF ' OVERDO this however else may stress Picaxe! Thus switch if infra =3 then RLEDON ' on/off the red LED (or push buzzer) while white stays if infra =4 then WLEDWINK ' lit in background. Suit patient "bed call" or supermart. if infra =5 then RWLEDALT ' checkout query use ? Just issue users an IR remote with if infra =6 then RLEDWINK ' suitably labelled buttons. Receiver unit can be set up if infra =7 then BEEP ' to show nature of query by LED colour/pattern etc. Thus if infra =8 then WLEDBRIEF ' red=bedpan,flash red=urgent bedpan, red/white=too late! if infra =9 then WBEACON ' OR-maybe IR remote control a yard/entrance light array? WLEDON: '1 White LED on & stays on until switched off by 2 high 1:goto IRDEMO LEDSOFF: '2 Common off button for both red & white LEDs low 1:low 2:goto IRDEMO RLEDON: '3 White LED on & stays on until switched off by 2 high 2:goto IRDEMO WLEDWINK: '4 10 flashes from white LED for b4= 1 to 10:high 1 pause 200:low 1:pause 200 next b4:goto IRDEMO RWLEDALT: '5 red-white urgent alternating flashes for b5= 1 to 10:high 1:pause 50 low 1:pause 50:high 2:pause 50 low 2: pause 50:next b5 goto IRDEMO RLEDWINK: '6 10 flashes from red LED for b6= 1 to 10:high 2 pause 200:low 2:pause 200 next b6:goto IRDEMO BEEP: '7 Piezo sounder beeps - repeatedly if push held sound 7,(100,50) goto IRDEMO WLEDBRIEF: '8 White LED on for 5 secs, with 'hurry up' alert high 1:wait 5:low 1:pause 200 high 1:pause 200:low 1:pause 200 high 1:wait 3:low 1 goto IRDEMO WBEACON: b0=0 '9 Sends Morse CQ ( Ham jargon for "calling anyone") high 1:pause 300:low 1:pause 200:high 1:pause 100:low 1:pause 200 'C= -.-. high 1:pause 300:low 1:pause 200:high 1:pause 100:low 1 :pause 1000 high 1:pause 300:low 1:pause 200:high 1:pause 300:low 1:pause 200 'Q= --.- high 1:pause 100:low 1:pause 200:high 1:pause 300:low 1 :pause 100 wait 5 '*button* pseudo interupt- breaks out of beacon loop button 0,0,50,50,b0,0,WBEACON 'via James =>penidrawltd@btinternet.com. May need b0 'tweaking still for reliability? Ref Editor-Help etc goto IRDEMO '(Button a sophisticated Basic Stamp debounce/branch)