dimanche 16 février 2014

Clavier Matriciel


le schémas du clavier  du site "modelisme.com "



 Utilisation de clavier matriciel 4 x3 boutons
    tiptopboards.com
    Rolland 23 08 2013
   http://tiptopboards.free.fr/arduino_forum/viewtopic.php?f=2&t=20
   

    // télécharger et installer la librairie Keypad
    //Traduction Google
   
//===================================================
    #include <Keypad.h>

    //Définition du clavier 4 x3 boutons
    const byte ROWS = 4; //4 lignes
    const byte COLS = 3; //3 colonnes
    // Donner un code Ascii aux 16 touches, par exemple 0-F
    char keys[ROWS][COLS] = {
      {'1','2','3'},
      {'4','5','6'},
      {'7','8','9'},
      {'A','0','B'}
    };
    byte rowPins[ROWS] = {5, 4, 3, 2}; //les 4 lignes du clavier sur les pins arduino digitales
    byte colPins[COLS] = {8, 7, 6}; //les 3colonnes du clavier

    //Créer cet objet clavier
    Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );// defaut ???

    void setup(){
      Serial.begin(115200);   //Moniteur série (écran PC)
      Serial.println("Utilisation du clavier 12 touches");
    }

    void loop(){
      char key = keypad.getKey();   //Surveiller le calvier

      if (key != NO_KEY){
        Serial.println(key);  //Afficher le code ascii de la touche appuyée
      }
    }


Aucun commentaire:

Enregistrer un commentaire