Page 215 - Tasarım Beceri Atölyeleri Öğretmen El Kitabı
P. 215

byte rowPins[ROWS] = {14, 15, 16, 17}; //Row pinouts of the keypad
               byte colPins[COLS] = {18, 19, 20, 21}; //Column pinouts of the keypad


               Keypad myKeypad = Keypad( makeKeymap(keyMap), rowPins, colPins, ROWS, COLS);
               LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)



               void setup() {
                 lcd.begin(16,2);
                 pinMode(buzzer, OUTPUT); // Set buzzer as an output
                 pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
                 pinMode(echoPin, INPUT); // Sets the echoPin as an Input
               }


               void loop() {
                 if (activateAlarm) {

                   lcd.clear();
                   lcd.setCursor(0,0);
                   lcd.print(“Alarm will be”);
                   lcd.setCursor(0,1);
                   lcd.print(“activated in”);

                   int countdown = 9; // 9 seconds count down before activating the alarm
                   while (countdown != 0) {
                     lcd.setCursor(13,1);
                     lcd.print(countdown);
                     countdown--;

                     tone(buzzer, 700, 100);
                     delay(1000);
                   }







                                                                                                                     207
   210   211   212   213   214   215   216   217   218   219   220