Page 57 - MODUL PRAKTIKUM MIKROKONTROLER - MIKROPROSESOR
P. 57

Modul Praktikum Sistem Mikroprosesor & Mikrokontroler
                        (MT-UN-2022)




























                        Tuliskan program dibawah ini:

                        #include <LiquidCrystal.h>
                        LiquidCrystal lcd(12,11,5,4,3,2);

                        #include <Keypad.h>
                        const byte ROWS = 4; //four rows
                        const byte COLS = 4; // four columns
                        char keys[ROWS][COLS] = {
                          {'7','8','9','/'},
                          {'4','5','6','x'},
                          {'1','2','3','-'},
                          {'C','0','=','+'}
                        };
                        byte rowPins[ROWS] = {A0, A1, A2, A3};
                        byte colPins[COLS] = {10, 9, 8, 7};

                        Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS
                        );

                        void setup() {
                          lcd.begin(16, 2);
                        }
                        void loop() {
                          // put your main code here, to run repeatedly:
                          char key = kpd.getKey();
                          if (key!=NO_KEY){
                            lcd.print(key);
                          }
                        }

                        6.5    Soal Post Test

                               Buatlah program kalkulator sederhana menggunakan keypad dan LCD!





                                                                                                        50
   52   53   54   55   56   57   58   59   60   61   62