Modifications

Sauter à la navigation Sauter à la recherche
1 831 octets ajoutés ,  17 mai 2012 à 21:27
Ligne 118 : Ligne 118 :     
Lorsque vous pressez une touche, cette dernière est affichée dans le moniteur série.
 
Lorsque vous pressez une touche, cette dernière est affichée dans le moniteur série.
 +
<nowiki>//  FR: Exemple d'utilisation de la librairie KeyPad - Compatible Arduino V1.0
 +
//  EN: Sample of use of the KeyPad library - Compatible Arduino V1.0
 +
//
 +
// FR: Si vous voulez utiliser ce programme sur un Arduino V1.0 vous aurez probablement
 +
//    besoin de télécharger la librairie Keypad et de la modifier (une seule ligne) pour
 +
//    pouvoir la compiler sans erreur.
 +
//    Pour plus de détail, voir cet article sur le Wiki de MC Hobby.
 +
//        http://mchobby.be/wiki/index.php?title=KeyPad#Librairie_pour_Arduino_1.0
 +
//
 +
// EN: If you want to compile this program under Arduino V1.0, you will probably need to
 +
//    download the Keypad library and to modify it (only one line). After the modification
 +
//    The program will compile without error.
 +
//      For more details, please see this article on the MC Hobby Wiki
 +
//        http://mchobby.be/wiki/index.php?title=KeyPad#Librairie_pour_Arduino_1.0
 +
//
 +
// Source: http://arduino.cc/fr/Main/LibrairieKeypad
 +
// License: CC-BY-SA for source
 +
// License: CC-BY-SA for modification (by MC Hobby, http://www.mchobby.be )
 +
//
 +
#include <Keypad.h>
   −
xxx
+
const byte ROWS = 4; //4 Lignes (4 Lines, 4 rows)
 +
const byte COLS = 4; //4 Colonnes (4 columns)
 +
char keys[ROWS][COLS] = {
 +
  {'1','2','3', 'A'},
 +
  {'4','5','6', 'B'},
 +
  {'7','8','9', 'C'},
 +
  {'*','0','#', 'D'}
 +
};
 +
 
 +
// FR: Connecté sur les lignes du KeyPad (L1, L2, L3, L4)
 +
// EN: Connect to the row pinouts of the keypad
 +
byte rowPins[ROWS] = {9, 8, 7, 6};
 +
 
 +
// FR: Connecté sur les colonnes dy KeyPad (C1, C2, C3, C4)
 +
// EN: connect to the column pinouts of the keypad
 +
byte colPins[COLS] = {5, 4, 3, 2};
 +
 
 +
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 +
 
 +
void setup(){
 +
  Serial.begin(9600);
 +
}
 +
 
 +
void loop(){
 +
  char key = keypad.getKey();
 +
 
 +
  if (key != NO_KEY){
 +
    Serial.println(key);
 +
  }
 +
}
 +
</nowiki>
    
Voici le résultat que nous obtenons avec un Arduino R3 & Arduino 1.0
 
Voici le résultat que nous obtenons avec un Arduino R3 & Arduino 1.0
29 917

modifications

Menu de navigation