Author Options:

PICAXE Code? Answered

I am not able to understand why is FOR loop used for the irout command can someone please tell me.
Another ques can I use the serout pin for the IRout command

Heres the Code:

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


From the Picaxe basic commands manual at http://www.picaxe.com/docs/picaxe_manual2.pdf

"All commercial remote controls repeat the signal every 45ms whilst the button is held down. Therefore when using the PICAXE system higher reliability may be gained by repeating the transmission (e.g. 10 times) within a for..next loop."

Does this mean every time I make my code it has to have a FOR ...... NEXT loop for 10 times and I have to give 45ms delay?

Not necessary - It is done for reliability and depending on the distance you want the system to work over/the amount of reflection needed/the power output of the IR LEDs etc you may be able to get away with fewer pulses, reduced timing or even a single transmission you will need to experiment with your circumstances.

ALL Rev ed are saying if for good reliability - like commercial systems they suggest sending the pulse 10 times.

However 45ms is a very short time!

I'm not familiar with programming for Picaxe but this question is very vague. Is that a small section of the code or is it the full code? I'm assuming its not the full code. Posting the full code or giving us a link to the code would go a long way to helping us help you.

Thats the full code I took it from PICAXE's official website .
LINK> http://www.picaxe.com/BASIC-Commands/Digital-InputOutput/irout/
Scroll till the end of the page.

The for loop is used to flash the IR LED 10 times with 45 milliseconds between each flash. IR remotes flash the IR LED a certain number of times with specific delays between the flashes to indicate different button pushes. The example is just a small segment of code to demonstrate a common use of the function.