Snippets

Jason Matusiak IR Remote Repeater

Created by Jason Matusiak
/* autoResume.ino Example sketch for IRLib2
   Illustrates how to receive an IR signal, decode it and print
   information about it to the serial monitor.
   Uses an external buffer in the auto resume feature.
*/
/*
//This includes everything. Not generally recommended.
//It's better to include only the parts of library you really need.
//But for this example it's quick and easy. See "comboDump" example
//for a more efficient way.
#include "IRLibAll.h"

IRrecvPCI myReceiver(2); //create receiver and pass pin number
IRdecode myDecoder;   //create decoder

//Create a buffer that we will use for decoding one stream while
//the receiver is using the default buffer "recvGlobal.recvBuffer"
uint16_t myBuffer[RECV_BUF_LENGTH];

void setup() {
  Serial.begin(9600);
  delay(2000); while (!Serial); //delay for Leonardo
  //Enable auto resume and pass it the address of your extra buffer
  myReceiver.enableAutoResume(myBuffer);
  myReceiver.enableIRIn(); // Start the receiver
  Serial.println(F("Ready to receive IR signals"));
}

void loop() {
  //Continue looping until you get a complete signal received
  if (myReceiver.getResults()) {
    myDecoder.decode();           //Decode it
    myDecoder.dumpResults(true);  //Now print results. Use false for less detail
    myReceiver.enableIRIn();      //Restart receiver
  }
}
*/


/* send.ino Example sketch for IRLib2
 *  Illustrates how to send a code.
 */

#include <IRLibSendBase.h>    // First include the send base
//Now include only the protocols you wish to actually use.
//The lowest numbered protocol should be first but remainder 
//can be any order.
#include <IRLib_P01_NEC.h>      
#include <IRLibCombo.h>     // After all protocols, include this
// All of the above automatically creates a universal sending
// class called "IRsend" containing only the protocols you want.
// Now declare an instance of that sender.

const uint32_t POWER = 0x00FFA25D;
const uint32_t MENU  = 0x00FF22DD;
const uint32_t UP    = 0x00FFA857;
const uint32_t DOWN  = 0x00FF18E7;
const uint32_t LEFT  = 0x00FF6897;
const uint32_t RIGHT = 0x00FFB04F;
const uint32_t OK    = 0x00FF9867;
const uint32_t RTN   = 0x00FF42BD;
const uint32_t PLPAU = 0x00FF4AB5;
const uint32_t GAP   = 0xFFFFFFFF;

IRsend mySender;

void setup() {
  Serial.begin(9600);
  delay(2000); while (!Serial);
  Serial.println("Starting IR transmit procedures");
}

void sendCMD(uint32_t cmd)
{
    mySender.send(NEC,cmd,0);
    delay(250);
}


void loop() {
    //power up the unit
    Serial.println("Powering up the unit");
    sendCMD(POWER);
    
    //delay 25 seconds for the unit to power up
    Serial.println("Delaying 25 seconds for power up process");
    //delay(30000);
    unsigned long interval=25000; // the time we need to wait
    unsigned long previousMillis=0; // millis() returns an unsigned long.
    unsigned long currentMillis = millis(); // grab current time
    while ((unsigned long)(millis() - currentMillis) < interval) {}
        
    //setup the system to run for 300 minutes
    Serial.println("Setting timer for 300 minutes");
    sendCMD(MENU);
    sendCMD(MENU);
    sendCMD(RIGHT);
    sendCMD(RIGHT);
    sendCMD(OK);
    for(int i = 0; i < 10; i++)
    {
        sendCMD(DOWN);
    }
    sendCMD(MENU);
    sendCMD(MENU);
    
    //Select videos as the option to play
    Serial.println("Select Video as the option to play");
    sendCMD(LEFT);
    sendCMD(OK);

    //select SD card as source
    Serial.println("Selecting SD card as source");
    sendCMD(OK);

    //select vertical orientation
    Serial.println("Selecting vertical orientation folder");
    sendCMD(RIGHT);
    sendCMD(RIGHT);
    sendCMD(OK);

    //select Christmas folder
    Serial.println("Selecting Christmas folder");
    sendCMD(RIGHT);
    sendCMD(RIGHT);
    sendCMD(OK);

    //select the Christmas clips to show
    Serial.println("Selecting the clips to play");
    for(int i = 0; i < 4; i++)
    {
        sendCMD(RIGHT);
    }
    sendCMD(OK);
    //select the Christmas clips to show
    for(int i = 0; i < 3; i++)
    {
        sendCMD(RIGHT);
        sendCMD(OK);
    }
    
    //play the clips!!!!
    Serial.println("Playing the clips!!!!!");
    sendCMD(PLPAU);
    
    //loop forever since your work is done!
    Serial.println("Until tomorrow night, my work here is done....");
    while(1){}

}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.