Exemple (Télécommande 1 et 2),
Codes Touches Colonne 1 Colonne C2 Colonne C3 Ligne 1 0xBA45FF00 0xB946FF00 0xB847FF00 Ligne 2 0xBB44FF00 0xBF40FF00 0xBC43FF00 Ligne 3 0xF807FF00 0xEA15FF00 0xF609FF00 Ligne 4 0xE916FF00 0xE619FF00 0xF20DFF00 Ligne 5 0xF30CFF00 0xE718FF00 0xA15EFF00 Ligne 6 0xF708FF00 0xE31CFF00 0xA55AFF00 Ligne 7 0xBD42FF00 0xAD52FF00 0xB54AFF00
autre exemple (Télécommande 3)...
Codes Touches Colonne 1 Colonne C2 Colonne C3 Ligne 1 0xB24DFF00 0xAB54FF00 0xE916FF00 Ligne 2 0xB34CFF00 0xFA05FF00 0xF30CFF00 Ligne 3 0xF50AFF00 0xBF40FF00 0xE11EFF00 Ligne 4 0xED12FF00 0xFD02FF00 0xE31CFF00 Ligne 5 0xF609FF00 0xE21DFF00 0xE01FFF00 Ligne 6 0xF20DFF00 0xE619FF00 0xE41BFF00 Ligne 7 0xEE11FF00 0xEA15FF00 0xE817FF00
#include "IRremote/src/IRremote.h"
int receiver = 5; // Signal Pin for IR receiver
IRrecv irrecv(receiver);
uint32_t last_decodedRawData = 0;
void decodeIR() {
if (irrecv.decodedIRData.flags) {
irrecv.decodedIRData.decodedRawData = last_decodedRawData;
Serial.print("->REPEAT 0x");
Serial.print(irrecv.decodedIRData.decodedRawData, HEX);
Serial.print("\t\t --> ");
} else {
Serial.print("IR code: 0x");
Serial.print(irrecv.decodedIRData.decodedRawData, HEX);
Serial.print("\t\t Touche: ");
}
// Selon le code reçu
switch (irrecv.decodedIRData.decodedRawData) {
case 0xBA45FF00:
Serial.println("POWER");
break;
case 0xB847FF00:
Serial.println("FUNC/STOP");
break;
case 0xB946FF00:
Serial.println("VOL+");
break;
case 0xBB44FF00:
Serial.println("FAST BACK");
break;
case 0xBF40FF00:
Serial.println("PAUSE");
break;
case 0xBC43FF00:
Serial.println("FAST FORWARD");
break;
case 0xF807FF00:
Serial.println("DOWN");
break;
case 0xEA15FF00:
Serial.println("VOL-");
break;
case 0xF609FF00:
Serial.println("UP");
break;
case 0xE619FF00:
Serial.println("EQ");
break;
case 0xF20DFF00:
Serial.println("ST/REPT");
break;
case 0xE916FF00:
Serial.println("0");
break;
case 0xF30CFF00:
Serial.println("1");
break;
case 0xE718FF00:
Serial.println("2");
break;
case 0xA15EFF00:
Serial.println("3");
break;
case 0xF708FF00:
Serial.println("4");
break;
case 0xE31CFF00:
Serial.println("5");
break;
case 0xA55AFF00:
Serial.println("6");
break;
case 0xBD42FF00:
Serial.println("7");
break;
case 0xAD52FF00:
Serial.println("8");
break;
case 0xB54AFF00:
Serial.println("9");
break;
default:
Serial.println("!!! Inconnue !!!");
}
last_decodedRawData = irrecv.decodedIRData.decodedRawData;
delay(500); // Pause de 500ms avant nouveau test
}
void setup() {
Serial.begin(9600);
Serial.println("IR Receiver Button Decode");
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode()) {
decodeIR();
irrecv.resume();
}
}