IR comands and how?

Satchid

Member
Dear All,
Sorry, I forgot hos to input code, can someone please remind me?

How is IRin and IRout really works?

I see the program for IROUT: in the command pdf.

[ for b1 = 1 to 10
irout B.1,1,5
pause 45
next b1]

The above is running in a "for next" loop and then pause 0.045 seconds. I would like to keep constant sending of say push button "5"

Do I have a coded constant pulse steam if i do the following?

[Main:

irout b.1,1,5 ;send IR signal pulsed as per button 6

goto main]


Then I need to receive the above pulse stream in another picaxe. This IR sensor is very precise focused towards the IR led on an other picaxe. If it moves away of the IR led direction, then there is no input anymore and the IR stream is 0.

I see the program for IRIN:

[main: irin [1000,main],C.3,b0 ; wait for new signal
if b0 = 1 then swon1 ; switch on 1
if b0 = 4 then swoff1 ; switch off 1
goto main

swon1: high B.1
goto main
swoff1: low B.1
goto main]

Can I do this to correspond with mi previous if it is correct:

[main: irin ,C.3,b0 ;Read pulse stream on C.3 and put in b0

if b0 = 5 then gostraight ; go to gostraight

els high B.1 ; start motor

goto main

gostraight: low B.1

goto main]

I could probably do this with a non modulated IR LED but where I intend to use this, I have lots of strong (hot) lights around that could influence the IR receiver. So, by modulating the sours and receiver, I hope to avoid interference from hot transmittors.


Thank you for helping me on the way.
Willy
 

pxgator

Senior Member
If you list the PICAXE chip are you going to use....08M2, 14M2, etc...??
Someone can post some simple IRIN/IROUT code for you to try.
 
Last edited:

pxgator

Senior Member
Assuming that you are using a PICAXE 14M2 here is a couple of code snippets.
The first is for IR out and the push buttons brings pin C.0 or C.1 to ground when pushed.
Continuous codes will be sent as long as either button is 'pushed'

Code:
[color=Navy]#Picaxe [/color][color=Black]14M2[/color]
[color=Navy]#No_Data[/color]

[color=Blue]symbol [/color][color=Purple]PB1 [/color][color=DarkCyan]= [/color][color=Purple]pinC.1               [/color][color=Green];pushbutton on C.1 leg 6[/color]
[color=Blue]symbol [/color][color=Purple]PB2 [/color][color=DarkCyan]= [/color][color=Purple]pinC.0               [/color][color=Green];pushbutton on C.0 leg 7[/color]
[color=Blue]pullup [/color][color=Navy]%1100000000                [/color][color=Green];enable pullup on C.0 and C.1[/color]
[color=Blue]symbol outIR [/color][color=DarkCyan]= [/color][color=Blue]B.5                [/color][color=Green];IR out for pin B.5 leg 8 [/color]

[color=Black]main: 
  [/color][color=Blue]if [/color][color=Purple]PB1 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=DarkCyan]AND [/color][color=Purple]PB2 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then   [/color][color=Green];check state of PB1
  [/color][color=Blue]irout outIR[/color][color=Black],[/color][color=Navy]1[/color][color=Black],[/color][color=Navy]1               [/color][color=Green];send continuous IR code of 1 
  [/color][color=Blue]pause [/color][color=Navy]45[/color][color=Black]:[/color][color=Blue]endif
  
  if [/color][color=Purple]PB2 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=DarkCyan]AND [/color][color=Purple]PB1 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then   [/color][color=Green];check state of PB2
  [/color][color=Blue]irout outIR[/color][color=Black],[/color][color=Navy]1[/color][color=Black],[/color][color=Navy]4               [/color][color=Green];send continuous IR code of 4 
  [/color][color=Blue]pause [/color][color=Navy]45[/color][color=Black]:[/color][color=Blue]endif
  
goto [/color][color=Black]main                         [/color]

This one is for IR reception.

Code:
[color=Navy]#Picaxe [/color][color=Black]14M2[/color]
[color=Navy]#No_Data[/color]


[color=Blue]symbol inIR [/color][color=DarkCyan]= [/color][color=Blue]C.0               [/color][color=Green];IR input pin leg 7[/color]

[color=Black]main:
  [/color][color=Blue]irin [PLAIN][[/PLAIN][/color][color=Navy]1000[/color][color=Black],main[/color][color=Blue][PLAIN]][/PLAIN][/color][color=Black],[/color][color=Blue]inIR[/color][color=Black],[/color][color=Purple]b0      [/color][color=Green];wait for new signal
  [/color][color=Blue]if [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then [/color][color=Black]swon1          [/color][color=Green];switch on 1
  [/color][color=Blue]if [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Navy]4 [/color][color=Blue]then [/color][color=Black]swoff1         [/color][color=Green];switch off 1[/color]
[color=Blue]goto [/color][color=Black]main

swon1: [/color][color=Blue]high B.1
  goto [/color][color=Black]main

swoff1: [/color][color=Blue]low B.1
  goto [/color][color=Black]main[/color]
 
Last edited:
Top