Rabu, 16 April 2014

ARDUINO - Keypad 3x4 Example

#include <Keypad.h>

const byte ROWS = 4; //4 baris
const byte COLS = 3; //3 kolom
char keys[ROWS][COLS] =
{
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //hubungkan ke pin baris keypad
byte colPins[COLS] = {8, 7, 6}; //hubungkan ke pin kolom keypad

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);
  }
}

Tidak ada komentar:

Posting Komentar