Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Input Multi keypad
- Created by
- papermindvention.blogspot.com
- 19 March 2018 */
- #include <Keypad.h>
- String inString="";
- const byte ROWS = 4;
- const byte COLS = 4;
- char keys[ROWS][COLS] = {
- {'1','4','7','*'},
- {'2','5','8','0'},
- {'3','6','9','#'},
- {'A','B','C','D'} };
- byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
- byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad
- Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
- void setup(){ Serial.begin(9600); }
- void loop(){
- char inChar = keypad.getKey();
- if (inChar){
- /* periksa apakah nilai yang diinputkan berupa angka */
- if (isDigit(inChar)) { inString += inChar; }
- /*periksa apakah nilai yang diinputkan berupa huruf Alphabet */
- if (isAlpha(inChar)) { inString += inChar; }
- /* jika tombol * ditekan, maka tampilkan nilai yang diinputkan. */
- if (inChar == '*') {
- Serial.print("nilai yang anda memasukkan :");
- Serial.println(inString);
- inString = "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment