/*
Arduino | general-help
egnaroky — 7/3/24 at 8:27 PM
are there any known issues regarding the IRremote library?
i am having trouble getting my irreceiver to work and i do
not know what the problem is.
*/
#include <IRremote.hpp>
#include "pitches.h"
const int RECV_PIN = 7;
const int BUZZ_PIN = 11;
const long DURATION = 220;
void playTone(int command) {
Serial.print("Note : ");
IrReceiver.stopTimer();
switch (command) {
case 104: tone(BUZZ_PIN, NOTE_C4, DURATION); Serial.print(NOTE_C4); break;
case 48: tone(BUZZ_PIN, NOTE_D4, DURATION); Serial.print(NOTE_D4); break;
case 24: tone(BUZZ_PIN, NOTE_E4, DURATION); Serial.print(NOTE_E4); break;
case 122: tone(BUZZ_PIN, NOTE_F4, DURATION); Serial.print(NOTE_F4); break;
case 16: tone(BUZZ_PIN, NOTE_G4, DURATION); Serial.print(NOTE_G4); break;
case 56: tone(BUZZ_PIN, NOTE_A5, DURATION); Serial.print(NOTE_A5); break;
case 90: tone(BUZZ_PIN, NOTE_B5, DURATION); Serial.print(NOTE_B5); break;
case 66: tone(BUZZ_PIN, NOTE_C5, DURATION); Serial.print(NOTE_C5); break;
case 74: tone(BUZZ_PIN, NOTE_D5, DURATION); Serial.print(NOTE_D5); break;
case 82: tone(BUZZ_PIN, NOTE_E5, DURATION); Serial.print(NOTE_E5); break;
default: break;
}
Serial.println(" Hz\n");
delay(DURATION);
IrReceiver.restartTimer(DURATION * 1000);
}
void setup() {
Serial.begin(9600);
IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK);
pinMode(BUZZ_PIN, OUTPUT);
}
void loop() {
if (IrReceiver.decode()) {
//IrReceiver.printIRResultShort(&Serial);
int command = IrReceiver.decodedIRData.command;
Serial.print("Command: ");
Serial.println(command);
playTone(command);
IrReceiver.resume();
}
}