Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Ollivier JULLIEN
- // MARSEILLE - 2020
- // 100% libre de droits
- // Télé commande PHILIPS 37 boutons https://imtc.qccdn.fr/test/adaptateur-tnt-hd-mpeg4/zoom/philips-dtr3000_003.jpg (Décodeur TNT ??)
- // Ecran LCD RVB https://wiki.dfrobot.com/Gravity__I2C_16x2_Arduino_LCD_with_RGB_Backlight_Display_SKU__DFR0464
- // 1 BP
- // 8 LEDs
- // exercice de d'utilisation de la télécommande
- // et découverte de l'écran
- // Une action sur chaque bouton
- // une action sur le BP
- // = 38 action sur 2 pins (intéressant, non ?)
- // pas mal pour piloter mes futurs projets (tant que je n'ai besoin que du simple clic)
- // le code pour récupérer se trouve sur ce lien : https://pastebin.com/0rNwwFq5
- // (fichier lourd, mais fonctionnel, c'est la première version)
- #include <avr/pgmspace.h>
- #include <IRremote.h>
- int LedIRLecture = 11;
- IRrecv recepteurIR(LedIRLecture);
- decode_results resultat;
- #include <Wire.h>
- #include <DFRobot_RGBLCD.h>
- DFRobot_RGBLCD lcd(16, 2);
- int r, v, b;
- int ancienR, ancienV, ancienB;
- const char valeurBouton_0[] PROGMEM = "fb003bc4";
- const char valeurBouton_1[] PROGMEM = "fb00d12e";
- const char valeurBouton_2[] PROGMEM = "fb00936c";
- const char valeurBouton_3[] PROGMEM = "fb0013ec";
- const char valeurBouton_4[] PROGMEM = "fb009966";
- const char valeurBouton_5[] PROGMEM = "fb00b34c";
- const char valeurBouton_6[] PROGMEM = "fb00e31c";
- const char valeurBouton_7[] PROGMEM = "fb00639c";
- const char valeurBouton_8[] PROGMEM = "fb00a35c";
- const char valeurBouton_9[] PROGMEM = "fb0023dc";
- const char valeurBouton_10[] PROGMEM = "fb00f906";
- const char valeurBouton_11[] PROGMEM = "fb00d926";
- const char valeurBouton_12[] PROGMEM = "fb007b84";
- const char valeurBouton_13[] PROGMEM = "fb006b94";
- const char valeurBouton_14[] PROGMEM = "fb00db24";
- const char valeurBouton_15[] PROGMEM = "fb001be4";
- const char valeurBouton_16[] PROGMEM = "fb005ba4";
- const char valeurBouton_17[] PROGMEM = "fb002bd4";
- const char valeurBouton_18[] PROGMEM = "fb00eb14";
- const char valeurBouton_19[] PROGMEM = "fb00c13e";
- const char valeurBouton_20[] PROGMEM = "fb00738c";
- const char valeurBouton_21[] PROGMEM = "fb00b946";
- const char valeurBouton_22[] PROGMEM = "fb00bb44";
- const char valeurBouton_23[] PROGMEM = "fb000bf4";
- const char valeurBouton_24[] PROGMEM = "fb0033cc";
- const char valeurBouton_25[] PROGMEM = "fb00718e";
- const char valeurBouton_26[] PROGMEM = "fb00619e";
- const char valeurBouton_27[] PROGMEM = "fb00f10e";
- const char valeurBouton_28[] PROGMEM = "fb0049b6";
- const char valeurBouton_29[] PROGMEM = "fb00e11e";
- const char valeurBouton_30[] PROGMEM = "fb00c936";
- const char valeurBouton_31[] PROGMEM = "fb006996";
- const char valeurBouton_32[] PROGMEM = "fb0041be";
- const char valeurBouton_33[] PROGMEM = "fb00e916";
- const char valeurBouton_34[] PROGMEM = "fb0059a6";
- const char valeurBouton_35[] PROGMEM = "fb00fb04";
- const char valeurBouton_36[] PROGMEM = "fb00916e";
- const char *const valeur_recue[] PROGMEM = {
- valeurBouton_0, valeurBouton_1, valeurBouton_2, valeurBouton_3, valeurBouton_4, valeurBouton_5, valeurBouton_6, valeurBouton_7, valeurBouton_8, valeurBouton_9,
- valeurBouton_10, valeurBouton_11, valeurBouton_12, valeurBouton_13, valeurBouton_14, valeurBouton_15, valeurBouton_16, valeurBouton_17, valeurBouton_18, valeurBouton_19,
- valeurBouton_20, valeurBouton_21, valeurBouton_22, valeurBouton_23, valeurBouton_24, valeurBouton_25, valeurBouton_26, valeurBouton_27, valeurBouton_28, valeurBouton_29,
- valeurBouton_30, valeurBouton_31, valeurBouton_32, valeurBouton_33, valeurBouton_34, valeurBouton_35, valeurBouton_36
- };
- char monBufferValeur[15];
- const char nomBouton_0[] PROGMEM = "ON / OFF";
- const char nomBouton_1[] PROGMEM = "MUTE";
- const char nomBouton_2[] PROGMEM = "NEXT";
- const char nomBouton_3[] PROGMEM = "STOP";
- const char nomBouton_4[] PROGMEM = "REC";
- const char nomBouton_5[] PROGMEM = "INFO";
- const char nomBouton_6[] PROGMEM = "TV / RADIO";
- const char nomBouton_7[] PROGMEM = "MEDIA";
- const char nomBouton_8[] PROGMEM = "AUDIO";
- const char nomBouton_9[] PROGMEM = "BLEU";
- const char nomBouton_10[] PROGMEM = "EPG";
- const char nomBouton_11[] PROGMEM = "BACK";
- const char nomBouton_12[] PROGMEM = "HAUT";
- const char nomBouton_13[] PROGMEM = "BAS";
- const char nomBouton_14[] PROGMEM = "GAUCHE";
- const char nomBouton_15[] PROGMEM = "DROITE";
- const char nomBouton_16[] PROGMEM = "OK";
- const char nomBouton_17[] PROGMEM = "MENU";
- const char nomBouton_18[] PROGMEM = "EXIT";
- const char nomBouton_19[] PROGMEM = "USB";
- const char nomBouton_20[] PROGMEM = "FAV";
- const char nomBouton_21[] PROGMEM = "<<";
- const char nomBouton_22[] PROGMEM = ">>";
- const char nomBouton_23[] PROGMEM = "|<<";
- const char nomBouton_24[] PROGMEM = ">>|";
- const char nomBouton_25[] PROGMEM = "1";
- const char nomBouton_26[] PROGMEM = "2";
- const char nomBouton_27[] PROGMEM = "3";
- const char nomBouton_28[] PROGMEM = "4";
- const char nomBouton_29[] PROGMEM = "5";
- const char nomBouton_30[] PROGMEM = "6";
- const char nomBouton_31[] PROGMEM = "7";
- const char nomBouton_32[] PROGMEM = "8";
- const char nomBouton_33[] PROGMEM = "9";
- const char nomBouton_34[] PROGMEM = "0";
- const char nomBouton_35[] PROGMEM = "TTX";
- const char nomBouton_36[] PROGMEM = "SUBTITLE";
- const char *const nom_valeur_recue[] PROGMEM = {
- nomBouton_0, nomBouton_1, nomBouton_2, nomBouton_3, nomBouton_4, nomBouton_5, nomBouton_6, nomBouton_7, nomBouton_8, nomBouton_9,
- nomBouton_10, nomBouton_11, nomBouton_12, nomBouton_13, nomBouton_14, nomBouton_15, nomBouton_16, nomBouton_17, nomBouton_18, nomBouton_19,
- nomBouton_20, nomBouton_21, nomBouton_22, nomBouton_23, nomBouton_24, nomBouton_25, nomBouton_26, nomBouton_27, nomBouton_28, nomBouton_29,
- nomBouton_30, nomBouton_31, nomBouton_32, nomBouton_33, nomBouton_34, nomBouton_35, nomBouton_36
- };
- char monBufferNom[20];
- int boutonActif;
- const int pinLEDTemoin = 3;
- bool etatLED = false;
- const int pinLEDRouge = 9;
- bool etatLEDRouge = false;
- const int pinLEDRougeModule = 8;
- bool etatLEDRougeModule = false;
- const int pinLEDJauneModule = 7;
- bool etatLEDJauneModule = false;
- const int pinLEDVertModule = 5;
- bool etatLEDVertModule = false;
- const int pinLEDBleuModule = 4;
- bool etatLEDBleuModule = false;
- const int pinLEDBlancModule = 12;
- bool etatLEDBlancModule = false;
- const int pinBoutonBP = 6;
- bool etatBP = true;
- bool ancienEtatBP = false;
- int rotationCouleur = 0;
- void recupInfos (const char *const tableauValeur[], const char *const tableauNom[], int rang) {
- strcpy_P(monBufferValeur, (char *)pgm_read_word(&(tableauValeur[rang])));
- strcpy_P(monBufferNom, (char *)pgm_read_word(&(tableauNom[rang])));
- }
- void afficheResultats (String valeur, String nom) {
- lcd.noCursor();
- lcd.stopBlink();
- lcd.setCursor(0, 0);
- lcd.print(F("Code : "));
- lcd.print(valeur);
- lcd.setCursor(0, 1);
- lcd.print(F(" "));
- lcd.setCursor(0, 1);
- lcd.print(F("Bouton "));
- lcd.print(nom);
- }
- #define __FILENAME__ (strrchr("\\" __FILE__, '\\') + 1)
- void setup() {
- recepteurIR.enableIRIn();
- pinMode(pinLEDTemoin, OUTPUT);
- pinMode(pinLEDRouge, OUTPUT);
- pinMode(pinLEDRougeModule, OUTPUT);
- pinMode(pinLEDJauneModule, OUTPUT);
- pinMode(pinLEDVertModule, OUTPUT);
- pinMode(pinLEDBleuModule, OUTPUT);
- pinMode(pinLEDBlancModule, OUTPUT);
- pinMode(pinBoutonBP, INPUT);
- lcd.init();
- r = 255;
- v = 204;
- b = 0;
- lcd.setRGB(r, v, b);
- lcd.setCursor(0, 0);
- lcd.print(F("*INITIALISATION*"));
- lcd.setCursor(0, 1);
- lcd.print(F("BIENVENUS =^..^="));
- delay(1500);
- lcd.setCursor(0, 0);
- lcd.print(__FILENAME__);
- lcd.setCursor(0, 1);
- lcd.print(" " __DATE__ " ");
- delay(1500);
- for (int positionCounter = 0; positionCounter < 20; positionCounter++) {
- lcd.scrollDisplayLeft();
- delay(500);
- }
- lcd.noDisplay();
- for (int positionCounter = 0; positionCounter < 36; positionCounter++) {
- lcd.scrollDisplayRight();
- }
- lcd.display();
- for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
- lcd.scrollDisplayLeft();
- delay(500);
- }
- delay(5000);
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print(F("A vous de jouer,"));
- lcd.setCursor(0, 1);
- lcd.print(F("(tele) commandez"));
- }
- void loop() {
- lcd.setRGB(r, v, b);
- etatBP = digitalRead(pinBoutonBP);
- if (etatBP == false && ancienEtatBP == true) {
- if (etatLED == false) {
- digitalWrite(pinLEDTemoin, HIGH);
- } else {
- digitalWrite(pinLEDTemoin, LOW);
- }
- etatLED = !etatLED;
- }
- ancienEtatBP = etatBP;
- delay(100);
- if (recepteurIR.decode(&resultat)) {
- String valeur = String(resultat.value, HEX); // on récupère la valeur reçue sous la forme d'une chaine de caractères
- if (valeur.substring(0, 2) == "fb" && valeur.length() == 8) { // si valeur reçue commence par fb et est de 8 caractères
- for (int i = 0; i < 37; i++) { // on compare aux valeurs enregistrées dans le tableau
- recupInfos (valeur_recue, nom_valeur_recue, i);
- if (valeur == monBufferValeur) { // si l'une correspond
- boutonActif = i; // son numero de rang devient le repère de ce bouton
- afficheResultats (monBufferValeur, monBufferNom);
- break;
- }
- }
- switch (boutonActif) {
- case 0: // le numéro de cas correspond à la position de la valeur correspondante dans le tableau
- for (int k = 0; k < 255; k++)
- {
- lcd.setPWM(REG_RED, k);
- lcd.setPWM(REG_GREEN, k);
- lcd.setPWM(REG_BLUE, k);
- delay(5);
- }
- delay(500);
- for (int l = 254; l >= 0; l--)
- {
- lcd.setPWM(REG_RED, l);
- lcd.setPWM(REG_GREEN, l);
- lcd.setPWM(REG_BLUE, l);
- delay(5);
- }
- delay(500);
- break;
- case 1:
- etatLEDBlancModule = !etatLEDBlancModule;
- if (etatLEDBlancModule == true) {
- digitalWrite(pinLEDBlancModule, HIGH);
- } else {
- digitalWrite(pinLEDBlancModule, LOW);
- }
- break;
- case 2:
- for (int positionCounter = 0; positionCounter < 15; positionCounter++) {
- lcd.scrollDisplayLeft();
- delay(500);
- }
- for (int positionCounter = 0; positionCounter < 31; positionCounter++) {
- lcd.scrollDisplayRight();
- delay(500);
- }
- for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
- lcd.scrollDisplayLeft();
- delay(500);
- }
- break;
- case 3:
- for (int z = 0; z < 10; z++) {
- lcd.display();
- delay(500);
- lcd.noDisplay();
- delay(500);
- }
- lcd.display();
- break;
- case 4:
- etatLEDRouge = !etatLEDRouge;
- if (etatLEDRouge == true) {
- digitalWrite(pinLEDRouge, HIGH);
- } else {
- digitalWrite(pinLEDRouge, LOW);
- }
- break;
- case 5:
- lcd.setCursor(0, 0);
- lcd.print(F(" Telecommande "));
- lcd.setCursor(0, 1);
- lcd.print(F(" a ZoLL "));
- break;
- case 6:
- etatLEDRougeModule = !etatLEDRougeModule;
- if (etatLEDRougeModule == true) {
- digitalWrite(pinLEDRougeModule, HIGH);
- } else {
- digitalWrite(pinLEDRougeModule, LOW);
- }
- break;
- case 7:
- etatLEDVertModule = !etatLEDVertModule;
- if (etatLEDVertModule == true) {
- digitalWrite(pinLEDVertModule, HIGH);
- } else {
- digitalWrite(pinLEDVertModule, LOW);
- }
- break;
- case 8:
- etatLEDJauneModule = !etatLEDJauneModule;
- if (etatLEDJauneModule == true) {
- digitalWrite(pinLEDJauneModule, HIGH);
- } else {
- digitalWrite(pinLEDJauneModule, LOW);
- }
- break;
- case 9:
- etatLEDBleuModule = !etatLEDBleuModule;
- if (etatLEDBleuModule == true) {
- digitalWrite(pinLEDBleuModule, HIGH);
- } else {
- digitalWrite(pinLEDBleuModule, LOW);
- }
- break;
- case 10:
- lcd.setCursor(0, 0);
- lcd.print(F(" ARDUINO FRANCE "));
- lcd.setCursor(0, 1);
- lcd.print(F("MARSEILLE - 2020"));
- for (int z = 0; z < 10; z++) {
- r = random(255);
- v = random(255);
- b = random(255);
- lcd.setRGB(r, v, b);
- lcd.display();
- delay(500);
- lcd.noDisplay();
- delay(500);
- }
- r = 255;
- v = 204;
- b = 0;
- lcd.setRGB(r, v, b);
- lcd.display();
- break;
- case 11:
- if (r == 255 && v == 204 && b == 0) {
- lcd.setCursor(0, 0);
- lcd.print(F(" MODE "));
- lcd.setCursor(0, 1);
- lcd.print(F(" VEILLE "));
- r = 1;
- v = 1;
- b = 1;
- } else {
- //afficheResultats (monBufferValeur, monBufferNom);
- r = 255;
- v = 204;
- b = 0;
- }
- break;
- case 12:
- ancienR = 255;
- ancienV = 204;
- ancienB = 0;
- if (rotationCouleur < 4) {
- rotationCouleur ++;
- } else {
- rotationCouleur = 0;
- }
- switch (rotationCouleur) {
- case 0:
- r = ancienR;
- v = ancienV;
- b = ancienB;
- break;
- case 1:
- r = 255;
- v = 0;
- b = 0;
- break;
- case 2:
- r = 0;
- v = 255;
- b = 0;
- break;
- case 3:
- r = 0;
- v = 0;
- b = 255;
- break;
- case 4:
- r = 255;
- v = 255;
- b = 255;
- break;
- }
- lcd.print(F(" "));
- lcd.print(rotationCouleur);
- break;
- case 13:
- ancienR = 255;
- ancienV = 204;
- ancienB = 0;
- if (rotationCouleur > 0) {
- rotationCouleur --;
- } else {
- rotationCouleur = 4;
- }
- switch (rotationCouleur) {
- case 0:
- r = ancienR;
- v = ancienV;
- b = ancienB;
- break;
- case 1:
- r = 255;
- v = 0;
- b = 0;
- break;
- case 2:
- r = 0;
- v = 255;
- b = 0;
- break;
- case 3:
- r = 0;
- v = 0;
- b = 255;
- break;
- case 4:
- r = 255;
- v = 255;
- b = 255;
- break;
- }
- lcd.print(F(" "));
- lcd.print(rotationCouleur);
- break;
- case 14:
- lcd.scrollDisplayLeft();
- break;
- case 15:
- lcd.scrollDisplayRight();
- break;
- case 16:
- etatLED = !etatLED;
- etatLEDRouge = !etatLEDRouge;
- if (etatLED == true) {
- digitalWrite(pinLEDTemoin, HIGH);
- } else {
- digitalWrite(pinLEDTemoin, LOW);
- }
- if (etatLEDRouge == true) {
- digitalWrite(pinLEDRouge, HIGH);
- } else {
- digitalWrite(pinLEDRouge, LOW);
- }
- break;
- case 17:
- for (int w = 0; w < 16; w++) {
- lcd.setCursor(w, 0);
- for (int x = 0; x < 2; x ++) {
- lcd.cursor();
- delay(250);
- lcd.noCursor();
- delay(125);
- }
- }
- break;
- case 18:
- for (int y = 15; y >= 0; y--) {
- lcd.setCursor(y, 1);
- lcd.blink();
- delay(1400);
- }
- lcd.stopBlink();
- break;
- case 19:
- lcd.print(F(" "));
- lcd.cursor();
- break;
- case 20:
- lcd.print(F(" "));
- lcd.blink();
- break;
- case 21:
- if (r >= 10) {
- r -= 10;
- } else {
- r = 0;
- }
- if (v >= 10) {
- v -= 10;
- } else {
- v = 0;
- }
- if (b >= 10) {
- b -= 10;
- } else {
- b = 0;
- }
- break;
- case 22:
- if ( v <= 245) {
- r += 10;
- } else {
- r = 255;
- }
- if (v <= 245) {
- v += 10;
- } else {
- v = 255;
- }
- if (b <= 245) {
- b += 10;
- } else {
- b = 255;
- }
- break;
- case 23:
- for (int positionCounter = 0; positionCounter < 15; positionCounter++) {
- lcd.scrollDisplayLeft();
- delay(500);
- }
- for (int positionCounter = 0; positionCounter < 31; positionCounter++) {
- lcd.scrollDisplayRight();
- }
- for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
- lcd.scrollDisplayLeft();
- delay(500);
- }
- break;
- case 24:
- for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
- lcd.scrollDisplayRight();
- delay(500);
- }
- for (int positionCounter = 0; positionCounter < 31; positionCounter++) {
- lcd.scrollDisplayLeft();
- }
- for (int positionCounter = 0; positionCounter < 15; positionCounter++) {
- lcd.scrollDisplayRight();
- delay(500);
- }
- break;
- case 25:
- r = 255;
- v = 0;
- b = 0;
- break;
- case 26:
- r = 255;
- v = 255;
- b = 0;
- break;
- case 27:
- r = 255;
- v = 255;
- b = 255;
- break;
- case 28:
- r = 0;
- v = 255;
- b = 255;
- break;
- case 29:
- r = 0;
- v = 0;
- b = 255;
- break;
- case 30:
- r = 255;
- v = 0;
- b = 255;
- break;
- case 31:
- r = 0;
- v = 255;
- b = 0;
- break;
- case 32:
- r = random(255);
- v = random(255);
- b = random(255);
- break;
- case 33:
- r = 125;
- v = 125;
- b = 125;
- break;
- case 34:
- r = 5;
- v = 5;
- b = 5;
- break;
- case 35:
- lcd.setCursor(0, 0);
- lcd.print(F("https://pastebin.com/vcvNTAE8"));
- lcd.setCursor(0, 1);
- lcd.print(F(" 100 % libre de droits 2020 "));
- for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
- lcd.scrollDisplayLeft();
- delay(500);
- }
- for (int positionCounter = 0; positionCounter < 45; positionCounter++) {
- lcd.scrollDisplayRight();
- delay(500);
- }
- for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
- lcd.scrollDisplayLeft();
- delay(500);
- }
- break;
- case 36:
- lcd.setCursor(0, 0);
- lcd.print(F(" MERCI =^..^= "));
- lcd.setCursor(0, 1);
- lcd.print(F(" TAI FOON "));
- break;
- }
- }
- recepteurIR.resume();
- delay(50);
- }
- }
Add Comment
Please, Sign In to add comment