Infrain Variable Question

Doogie

New Member
Hello, (I'm a newbie)
I want to grab the Infrain data and use it as a byte in my program. I'm using a 28X. I can debug the Infrain variable so my hardware is ok... but:

let pins = infrain 'doesn't seem to work.

let b1 = infrain
let pins = b1 'doesn't seem to work.

Could I (humbly)ask what I'm missing here?
Yours Doogie
 

kranenborg

Senior Member
Hello,

The INFRAIN (or INFRAIN2) command waits until a valid Sony SIRC code is received, decodes it and stores it in the variable 'infra'. You should subsequently test this variable to do something.

You could do something like:

<code><pre><font size=2 face='Courier'>
LOOP:
INFRAIN2
IF infra = 1 THEN DoThis
IF infra = 2 THEN DoThat
GOTO LOOP
DoThis:
'Some actions here
GOTO LOOP
DoThat:
'Some actions here
GOTO LOOP
</font></pre></code>

I have used this piece of code for my son's remotely controlled car. Note that the INFRAIN(2) commands halts any further command execution until a code is received!

By the way, I noticed that the INFRAIN2 deoodes differently from INFRAIN:
* INFRAIN2 correctly decodes the code sent by INFRAOUT,
* INFRAIN returns a value that is 1 less as compared to the code sent by INFRAOUT.

Does somebody have an explanation?

Best regards,
/Jurjen
http://www.kranenborg.org/ee/picaxe

Edited by - kranenborg on 23/08/2006 23:27:52
 

hippy

Ex-Staff (retired)
I appreciate this is your first post, but for future reference it's best to describe the problem in more detail than 'doesn't work'. That implies the program compiled and is behaving wrongly or strangely after being downloaded, when the problem here is a syntax error. The more specific you can be in explaining exactly what the problem is, along with any error messages, you are more likely to get more and quicker responses. That of course applies to everyone posting.

Anyway, the problem you have is that 'infrain' is not a variable; it should be 'infra'. You would use the INFRAIN or INFRAIN2 command and then access the value received in the 'infra' value ...

- INFRAIN
- LET pins = infra
- LET b0 = infra
- IF infra = 0 THEN finished
- <i>etc </i>

Good luck, and do come back if you have any more problems or questions.
 

Technical

Technical Support
Staff member
Jurjen
Look up the infraout command in the PICAXE manual (part 2). There is a table that clearly explain the differences between infrain and infrain2 values.
 

Doogie

New Member
Thanks much,
The problem was indeed my inability to RTFM... properly. Infra is the variable not infrain as I dyslexicaly wrote it in. Works like a charm now. Sheesh what a noob :)
Doogie
 
Top