Étape 2: ARDUINO CODE : Télécharger clavier bibliothèque
#include
const byte rangs = 4 ; Quatre rangées
const byte COLS = 3 ; Trois colonnes
Définir la vue d’ensemble
touches de char [lignes] [colonnes] = {{'1', « 2 », 3'}, {'4', '5', 6'}, {"7 «, '8', 9 »}, {'#','0 ',' *'}} ;
Branchez le clavier ROW0, ligne1, ligne2 et ROW3 ces broches de l’Arduino.
rowPins Byte [rangs] = {9, 8, 7, 6} ;
Branchez le clavier COL0, COL1 et COL2 ces broches de l’Arduino.
colPins Byte [CDL] = {12, 11, 10} ;
Créer le kpd clavier clavier = clavier (makeKeymap(keys), rowPins, colPins, lignes, colonnes) ;
#define ledpin 13
void setup()
{
pinMode(ledpin,OUTPUT) ;
digitalWrite (ledpin, HIGH) ;
Serial.Begin(9600) ;
}
void loop()
{
clé char = kpd.getKey() ;
if(Key) / / vérifier une clé valide.
{
commutateur (clé)
{
affaire « 1 » :
Serial.println(Key) ;
rupture ;
affaire « 2 » :
Serial.println(Key) ;
rupture ;
affaire « 3 » :
Serial.println(Key) ;
rupture ;
affaire « 4 » :
Serial.println(Key) ;
rupture ;
affaire « 5 » :
Serial.println(Key) ;
rupture ;
affaire « 6 » :
Serial.println(Key) ;
rupture ;
affaire « 7 » :
Serial.println(Key) ;
rupture ;
affaire « 8 » :
Serial.println(Key) ;
rupture ;
cas « 9 » :
Serial.println(Key) ;
rupture ;
affaire « 0 » :
Serial.println(Key) ;
rupture ;
cas ' *' :
Serial.println(Key) ;
rupture ;
cas « # » :
Serial.println(Key) ;
rupture ;
}
}
}