//The code for the receiver Arduino board follows:

const int IRin = 7; // IR receiver module connect

const int spk = 8;

int pulseTone;

int pulsePeriod;

unsigned long currentTime;

unsigned long oldTime;

void setup() {

  pinMode (IRin, INPUT_PULLUP);

  pinMode (spk, OUTPUT);

}

void loop() {

  pulseTone = digitalRead (IRin);

  if (pulseTone == LOW) {

    currentTime = millis();

    pulsePeriod = currentTime - oldTime; //ppicks up the second burst

    oldTime = currentTime;

    if (pulsePeriod > 6 && pulsePeriod < 14) {

      tone (spk, 500);

      delay (5000);

      noTone (spk); //speaker shuts off

      pulsePeriod = 0; //reset

    }

    if (pulsePeriod > 16 && pulsePeriod < 24) {

      tone (spk, 1000);

      delay (5000);

      noTone (spk); //speaker shuts off

      pulsePeriod = 0;

    }

    if (pulsePeriod > 26 && pulsePeriod < 34) {

      tone (spk, 5000);

      delay (5000);

      noTone (spk); //speaker shuts off

      pulsePeriod = 0;

    }

  }//end of IRin reception

}