-22%












微動開關 4×4 矩陣 16 按鍵/鍵盤模組
0 out of 5
NT$45 原始價格:NT$45。NT$35目前價格:NT$35。 (未稅)
- 描述
- 評價 (0)
描述
描述
微動開關 4×4 矩陣 16 按鍵/鍵盤模組 Arduino 可直接使用, 附 Arduino 範例
4X4矩陣鍵盤
16按鍵
單片機外擴鍵盤
優質按鍵
發貨清單:
4X4矩陣鍵盤一塊
不帶線
Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
4x4 keyboard matrix By Chris Rouse Oct. 2015 Connect: Row 1 to Arduino pin 2 Row 2 to Arduino pin 3 Row 3 to Arduino pin 4 Row 4 to Arduino pin 5 Column A to Arduino pin 8 Column B to Arduino pin 9 Column C to Arduino pin 10 Column D to Arduino pin 11 Key identification: (with connector at the top) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Connector: Rows Columns X X X X X X X X 1 2 3 4 A B C D (Rows link keys from left to right, columns link keys from top to bottom) ****************************************************/ int rowCounter =0; // row counter int columnCounter =0; // column counter int foundColumn = 0; boolean foundCol = false; int keyValue = 0; int noKey = 0; boolean readKey = false; int debounce = 300; // set this to the lowest value that gives the best result const int row1 = 2; const int row2 = 3; const int row3 = 4; const int row4 = 5; const int colA = 8; const int colB = 9; const int colC = 10; const int colD = 11; const int ledPin = 13; // onboard LED void setup(){ Serial.begin(9600); pinMode(row1, OUTPUT); pinMode(row2, OUTPUT); pinMode(row3, OUTPUT); pinMode(row4, OUTPUT); pinMode(colA, INPUT_PULLUP); pinMode(colB, INPUT_PULLUP); pinMode(colC, INPUT_PULLUP); pinMode(colD, INPUT_PULLUP); // pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // turn LED off } void loop(){ if(noKey == 16){ // no keys were pressed readKey = true; // keyboard is ready to accept a new keypress } noKey = 0; for(rowCounter=row1; rowCounter<(row4 +1); rowCounter++){ scanRow(); // switch on one row at a time for(columnCounter = colA; columnCounter <colD +1; columnCounter++){ readColumn(); // read the switch pressed if (foundCol== true){ keyValue =(rowCounter-row1) +4*(columnCounter - colA); } } } if(readKey==true && noKey == 15){ // a key has been pressed Serial.println(keyValue); // used for debug if (keyValue == 13){ digitalWrite(ledPin, !digitalRead(ledPin)); // toggles LED ON/OFF } else{ digitalWrite(ledPin, LOW); } /******************************************************** // call to part of the sketch that will use the key number */ //******************************************************* readKey = false; // rest the flag delay(debounce); // debounce } } void scanRow(){ for(int j =row1; j < (row4 +1); j++){ digitalWrite(j, HIGH); } digitalWrite(rowCounter , LOW); // switch on one row } void readColumn(){ foundColumn = digitalRead(columnCounter); if(foundColumn == 0){ foundCol = true; } else{ foundCol=false; noKey=noKey +1; // counter for number of empty columns } } |
評價 (0)
相關商品
-
-
按鍵 / 輸入 / 人機介面模組
Grove – Gesture PAJ7620U2 手勢感測器
0 out of 5NT$480原始價格:NT$480。NT$420目前價格:NT$420。 (未稅)加入購物車產品速覽 -
按鍵 / 輸入 / 人機介面模組
Grove – Mouse Encoder 機械式旋轉編碼器
0 out of 5NT$219原始價格:NT$219。NT$210目前價格:NT$210。 (未稅)加入購物車產品速覽 -
按鍵 / 輸入 / 人機介面模組
Grove 5-Way Switch 5向開關模組 I2C 通訊
0 out of 5NT$320原始價格:NT$320。NT$200目前價格:NT$200。 (未稅)加入購物車產品速覽
商品評價
目前沒有評價。