//The code for the transmitting Arduino follows:

const int sound1 = 8;

const int sound2 = 9;

const int sound3 = 10;

const int IRout = 7;

int lowTone;

int medTone;

int highTone;

int sound;

int timer;

void setup() {

  pinMode (sound1, INPUT_PULLUP);

  pinMode (sound2, INPUT_PULLUP);

  pinMode (sound3, INPUT_PULLUP);

  pinMode (IRout, OUTPUT); // to IR LED section

}

void loop() {

  lowTone = digitalRead (sound1);

  medTone = digitalRead (sound2);

  highTone = digitalRead (sound3);

  if (lowTone == LOW) {

    sound = 1;

  }

  if (medTone == LOW) {

    sound = 2;

  }

  if (highTone == LOW) {

    sound = 3;

  }

  switch (sound) {

    case 1:

      while (timer < 10) {

        tone (IRout, 38000);//outputs a short duration 38,000 tone

        delay (2);

        noTone (IRout);

        delay (8); //total period 10 ms

        timer = timer + 1;

      }//sends 10 times

      break;

    case 2:

      while (timer < 10) {

        tone (IRout, 38000);

        delay (2);

        noTone (IRout);

        delay (18); //period 20 ms

        timer = timer + 1;

      }

      break;

    case 3:

      while (timer < 10) {

        tone (IRout, 38000);

        delay (2);

        noTone (IRout);

        delay (28); //period 30 ms

        timer = timer + 1;

      }

      break;

  }

  sound = 0;

  timer = 0;

}