top of page

LE MODULE ME RECEPTEUR INFRAROUGE

Le module "Me Récepteur infrarouge" comporte un récepteur infrarouge associé à un microcontrôleur qui décode les ordres envoyés par une télécommande infrarouge. La portée de l'ensemble décodeur+télécommande est de 10 mètres. Une led bleue s'allume lors de la réception d'un ordre. Les fonctions contenues dans la bibliothèque Makeblock sont :

  • MeInfraredReceiver decodeur(PORT_X) où PORT_X est le port sur lequel est branché le module. Cette fonction permet de créer l'objet.

  • decodeur.read() renvoie le code du caractère reçu.

​

Le tableau ci- dessous donne les ports des cartes "Me Orion" et "Me Auriga" pouvant être connectés à ce module.

Exemple :

Nous souhaitons afficher sur un module "Me Afficheur LCD TFT" le numéro de la touche d'une télécommande infrarouge envoyé sur un module "Me Récepteur infrarouge".

Programme :

/* Decodeur_IR_Makeblock est un programme qui affiche sur le module "Me LCD TFT" le code de la touche d'une télécommande infrarouge. */

#include "MeOrion.h"                                                                                                           // appel des bibliothèques
#include <SoftwareSerial.h>

MeSerial serie(PORT_5);                                                                                                     // création de l'objet série (module branché sur le port 5)
MeInfraredReceiver decodeur(PORT_6);                                                                           // création de l'objet décodeur (module branché sur le port 6)

char code_recu;
 
void setup()
{
  serie.begin(9600);                                                                                                            // initialisation de la liaison série à 9600bit/s
  decodeur.begin();                                                                                                             // initialisation du décodeur
  serie.print("CLS(0);");                                                                                                       // on efface l'écran TFT
  serie.println("DR0;");                                                                                                        // configuration de l'écran TFT
}

void loop()
{
  if(decodeur.available())                                                                                                  // si on reçoit un code
  {
    code_recu = decodeur.read();                                                                                     // on lit le code
    serie.print("CLS(0);");                                                                                                   // en fonction du code, on affiche les messages
    switch(code_recu)
    {
       case IR_BUTTON_A:  serie.println("DS64(0,0,'Touche A',1);"); break;
       case IR_BUTTON_B:  serie.println("DS64(0,0,'Touche B',1);"); break;
       case IR_BUTTON_C:  serie.println("DS64(0,0,'Touche C',1);"); break;
       case IR_BUTTON_D:  serie.println("DS64(0,0,'Touche D',1);"); break;
       case IR_BUTTON_E:  serie.println("DS64(0,0,'Touche E',1);"); break;
       case IR_BUTTON_F:  serie.println("DS64(0,0,'Touche F',1);"); break;
       case IR_BUTTON_SETTING: serie.println("DS64(0,0,'Touche *',1);"); break;
       case IR_BUTTON_UP: serie.println("DS64(0,0,'Touche HAUT',1);"); break;
       case IR_BUTTON_DOWN: serie.println("DS64(0,0,'Touche BAS',1);"); break;
       case IR_BUTTON_LEFT: serie.println("DS64(0,0,'Touche GAUCHE',1);"); break;
       case IR_BUTTON_RIGHT: serie.println("DS64(0,0,'Touche DROITE',1);"); break;
       case IR_BUTTON_0: serie.println("DS64(0,0,'Touche 0',1);"); break;
       case IR_BUTTON_1: serie.println("DS64(0,0,'Touche 1',1);"); break;
       case IR_BUTTON_2: serie.println("DS64(0,0,'Touche 2',1);"); break;
       case IR_BUTTON_3: serie.println("DS64(0,0,'Touche 3',1);"); break;
       case IR_BUTTON_4: serie.println("DS64(0,0,'Touche 4',1);"); break;
       case IR_BUTTON_5: serie.println("DS64(0,0,'Touche 5',1);"); break;
       case IR_BUTTON_6: serie.println("DS64(0,0,'Touche 6',1);"); break;
       case IR_BUTTON_7: serie.println("DS64(0,0,'Touche 7',1);"); break;
       case IR_BUTTON_8: serie.println("DS64(0,0,'Touche 8',1);"); break;
       case IR_BUTTON_9: serie.println("DS64(0,0,'Touche 9',1);"); break;
       default: break;
    }
  }
}

bottom of page