​ ​ ​ ​ Background Infrared Receiver for 32-bit Codes - Page 2
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12

Thread: Background Infrared Receiver for 32-bit Codes

  1. #11
    New Member
    Join Date
    May 2009


    I don't really understand your code, as it's a bit beyond my ability. I have your program running on a picaxe 20X2 and it returns a code “ $E0E0 40BF “ for the power button on my remote. How do I get that into my program to turn a relay on.

  2. #12
    Senior Member
    Join Date
    Jan 1970
    Perth, Western Australia


    I don't visit these pages very often: over three years have passed since I created this thread. I have only just noticed your query.

    I have written some code and done a syntax check. However, I don't have a spare 20X2 to test the code in at the moment, so you'll have to do that. The following code appears in three 'chunks' and these need to be placed as indicated, in the original code.

    Add the following code in the definitions (Symbols) area:
    Symbol wDevID     = w3
    Symbol bDevID.Lo  = b6
    Symbol bDevID.Hi  = b7
    Symbol bIRCommand = b8
    Symbol bIRInverse = b9
    Symbol bIRCheck   = b10
    Symbol oRelay     = B.4                 'Choose your own pin that will operate the relay
    Symbol cDeviceID  = $E0E0               'Must match this ID with the chosen IR Remote Control
    Symbol cIROnOff   = $40                 '$40 is the On/Off button of the remote
    The next piece of code should be added near the end of the initialisation routine, before the "Do" command of the main loop
          Output oRelay                     'Initialise the relay pin as output
          Low oRelay                        'Ensure relay is not operated (default state)
    The main code should replace the code between the "If tInfrComplete = True Then" and its matching "EndIf" statement.
             If tInfrComplete = True Then
                ' ++++ Action any valid IR Code +++++++++++++++++
                SetFreq m32                                'SerTxd is 38,400 bits/sec - Only required if using SerTxd
                bInfReadPtr = rInfraDevID1                 'Initialise the source pointer to the IR buffer, byte 1
                Peek bInfReadPtr, bDevID.Lo, bDevID.Hi, bIRCommand, bIRInverse 'Fetch the 4 IR bytes
                If wDevID = cDeviceID Then                 'Is the IR from the correct IR Remote?
                   'Yes, the correct Device ID has been received
                   bIRCheck = bIRCommand Or bIRCheck
                   If bIRCheck = $FF Then                  'All bits should be set for a valid command: $FF = 255 = %11111111
                      'A valid command has been received
                      Select Case bIRCommand               'Analyse the command byte
                      Case cIROnOff                        'On-Off Button was pressed
                         Toggle oRelay                     'Invert the state of the relay driver pin
                      'Case                                'Another button	
                SetFreq m64                                'SerTxd is 76,800 bits/sec: too fast for Serial Port
                ' ++++ End Action any valid IR Code +++++++++++++
                'Reinitialise software Flags & Hardware interrupts for Infra Reception
                GoSub EnabInfra
    Last edited by inglewoodpete; 13-03-2014 at 13:32. Reason: Added new code


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts