2011年12月1日 星期四

Keypad - 4*3 數字鍵盤

從ICShopping買的4*3 Keypad
正面
背面
我這種懶惰的傢伙當然沒按照官方網站Keypad的說明裡的測每個pin的組合,我是直接接線然後看從結果和接線去調整出正確的接法。(外行人嘛)
/*
 * Keypad 1
 */
#define NumRows 4
#define NumCols 3
#define DebounceTime 20
const char keymap[NumRows][NumCols] = {
  { '1', '2', '3' },
  { '4', '5', '6' },
  { '7', '8', '9' },
  { '*', '0', '#' }
};

// pins
const int rowPins[ NumRows ] = { 5, 4, 3, 2 };
const int colPins[ NumCols ] = { 8, 7, 6 };
程式的其他部分是拿小歐的Arduino Cookbook第一版 5.5 Reading a Keypad來的。

沒有留言: