Michail Marinis
Published © GPL3+

Arduino Alarm System: SERENA

An alarm control panel made with an Arduino MEGA and a 3.2" Touch Screen.

BeginnerFull instructions provided6 minutes5,865
Arduino Alarm System: SERENA

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
3.2" TFT LCD Touch Screen
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

SERENA v.1.01

Arduino
Just upload the code to your Arduino board.
Some comments are in Greek, this will change soon.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SERENA Alarm System
//Author: Michael Marinis
//Copyright (C)2016 Michael Marinis. All Rights Reserved
//Website: http://www.youtube.com/SauROnmiKE
//
//This is the SERENA Alarm System, a two-function alarm system which gives
//the user the ability to auto-arm the alarm, or manually arm it when the user wants to.
//
//This program requires the UTFT & URTouch libraries from Henning Karlsen and a compatible LCD
//screen with it's shield.
//
//
//////////VERSIONS//////////
//0.10a: First build, basic functions
//0.20a: Minor improvements
//0.30a: Pass Input and Confirmation for a new Manual-Arm Password is done (12/11/2016)
//0.40a: Pass Input and Confirmation for a new Auto-Arm Password is done (12/11/2016)
//1.00a: Completed Arm Password Input & Check (12/11/2016, 19:16)
//1.10a: Completed the menu when the system is armed (without sending a signal to a relay or something else). The time and date will be added later. The Disarm button is only added (13/11/2016, 13:04)
//1.20a: Programmed the "DISARM" button. It prompts to the 5-Digit password input. Password check is also done, which disarms the alarm (without sending a signal to a relay or something else) (13/11/2016, 14:15)
//1.21a: Fixed an issue where the user couldn't type any numbers after the password confirmation check. If the user pressed "NO", he/she couldn't then type a new password until the "CLEAR" button was presed. This is now fixed (14/11/2016, 13:32)
//1.22a: The countdown timer for the auto-arming is now complete (14/11/2016, 15:46)
//1.30a: Auto-Arm Menu is complete. The Auto-Arm Menu displays the seconds left for the arm to be auto-armed again. The full disarm menu will be accessed via a push button due to the library's limitations (14/11/2016, 21:42)
//1.31a: Changed the "buf" variable from "-1" to "0". This resolved the bug, where the first push of any number button wouldn't do anything (16/11/2016, 00:45)
//1.40b: Added the "SET ARM PASSWORD" button which allows the user to modify the 4-digit password used to arm the alarm (16/11/2016, 14:33)
//1.41b: The "BACK" buttons from the "SET AUTO-ARM PASS", now redirect to the second page of the options menu, instead of the first one (16/11/2016, 16:21)
//1.42b: Completed the third options menu. It contains the buttons "SET TIME" and "SET DATE" (16/11/2016, 16:37)
//1.43b: Fixed a bug where the clear button on the disarm pass input wouldn't actually reset the "autoinput" array (17/11/2016, 00:05)
//1.44b: The "SET AUTO-ARM PASS" button, will now prompt the user to the second options menu when the password is changed, instead of the first one (18/11/2016, 10:02)
//The changes will be logged until the final version 1.00. After 1.00, the changes will be logged in the SERENA_changelog.txt file.
//1.00: Design of the full disarm function. The function will require the 6-Digit password and will prompt to the main menu of the alarm program. A buzzer is heard with every click of a button (8/1/2017, 20:53)
//////////FUTURE VERSIONS//////////
// *IDEAS FOR NEW VERSIONS WILL BE PUT HERE*
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#include <UTFT.h>
#include <URTouch.h>

UTFT  myGLCD(ITDB32WC, 38, 39, 40, 41);
URTouch  myTouch(6, 5, 4, 3, 2);

extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
int x;
int y;
int armpass[4] = {1, 2, 3, 4};
int autopass[5] = {1, 2, 3, 4, 5};
int manualpass[6] = {1, 1, 1, 1, 1, 1};
int timeinput[4];
int arminput[4];
int autoinput[5];
int manualinput[6];
int autolength = 0;
int manuallength = 0;
int buzzerpin = 8;
int systarm = 9;
int serenapin = 10;
int buttonpin = 13;
int autoarmtime = 40;
int autoarmtimemem = autoarmtime;
int month = 1;
int day = 1;
int year = 2016;

//CUSTOM FUNCTIONS


void alarmtitle()
{
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.clrScr();
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.drawLine(0, 14, 319, 14);
  myGLCD.print("SERENA ALARM SYSTEM v.1.01", CENTER, 1);
}

void title()//SEPARATED BECAUSE THE NAME IS NOT WANTED SOME TIMES
{
  alarmtitle();
  myGLCD.print("BY MICHAEL MARINIS", CENTER, 30);
}


void drawbutton1()
{
  myGLCD.setColor(192, 192, 192);
  myGLCD.fillRoundRect(20, 60, 300, 100);
}


void drawbutton2()
{
  myGLCD.setColor(192, 192, 192);
  myGLCD.fillRoundRect(20, 120, 300, 160);
}


void drawdisarm()
{
  myGLCD.setColor(192, 192, 192);
  myGLCD.fillRoundRect(20, 180, 300, 220);
  myGLCD.setColor(0, 0, 0);
  myGLCD.setBackColor(192, 192, 192);
  myGLCD.setFont(BigFont);
  myGLCD.print("DISARM", CENTER, 193);
}


void drawback()
{
  myGLCD.setColor(192, 192, 192);
  myGLCD.fillRoundRect(20, 180, 150, 210);
  myGLCD.setBackColor(192, 192, 192);
  myGLCD.setColor(0, 0, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.print("BACK", 70, 190);
}


void drawno()
{
  myGLCD.setColor(192, 192, 192);
  myGLCD.fillRoundRect(20, 180, 150, 210);
  myGLCD.setBackColor(192, 192, 192);
  myGLCD.setColor(0, 0, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.print("NO", 80, 190);
}


void drawyes()
{
  myGLCD.setColor(192, 192, 192);
  myGLCD.fillRoundRect(170, 180, 300, 210);
  myGLCD.setBackColor(192, 192, 192);
  myGLCD.setColor(0, 0, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.print("YES", 225, 190);
}


void drawnext()
{
  myGLCD.setColor(192, 192, 192);
  myGLCD.fillRoundRect(170, 180, 300, 210);
  myGLCD.setBackColor(192, 192, 192);
  myGLCD.setColor(0, 0, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.print("NEXT", 220, 190);
}


void drawbuttons()
{
  myGLCD.clrScr();
  int z;
  myGLCD.setFont(SmallFont);
  for (z = 0; z < 3; z++)
  {
    myGLCD.setColor(255, 0, 0);
    myGLCD.fillRoundRect(20 + (z * 60), 15, 60 + (z * 60), 55);
    myGLCD.setColor(255, 255, 255);
    myGLCD.setBackColor(255, 0, 0);
    myGLCD.printNumI(z + 1, 37 + (z * 60), 30);
  }

  for (z = 0; z < 3; z++)
  {
    myGLCD.setColor(255, 0, 0);
    myGLCD.fillRoundRect(20 + (z * 60), 70, 60 + (z * 60), 110);
    myGLCD.setColor(255, 255, 255);
    myGLCD.setBackColor(255, 0, 0);
    myGLCD.printNumI(z + 4, 37 + (z * 60), 85);
  }

  for (z = 0; z < 3; z++)
  {
    myGLCD.setColor(255, 0, 0);
    myGLCD.fillRoundRect(20 + (z * 60), 125, 60 + (z * 60), 165);
    myGLCD.setColor(255, 255, 255);
    myGLCD.setBackColor(255, 0, 0);
    myGLCD.printNumI(z + 7, 37 + (z * 60), 140);
  }

  for (z = 0; z < 3; z++)
  {
    myGLCD.setColor(255, 0, 0);
    myGLCD.fillRoundRect(190, 15 + (z * 55), 290, 55 + (z * 55));
  }


  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRoundRect(20, 175, 80, 205);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.printNumI(0, 48, 185);

  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("CLEAR", 221, 30);
  myGLCD.print("OK", 232, 85);
  myGLCD.print("BACK", 225, 140);
}


void optionsmenuend()
{
  myGLCD.clrScr();
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawLine(0, 14, 319, 14);
  myGLCD.setBackColor(255, 0, 0);
  alarmtitle();
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 0, 0);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.print("OPTIONS MENU", CENTER, 20);
  drawbutton1();
  drawbutton2();
  drawback();
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
}


void optionsmenu()
{
  myGLCD.clrScr();
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawLine(0, 14, 319, 14);
  myGLCD.setBackColor(255, 0, 0);
  alarmtitle();
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 0, 0);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.print("OPTIONS MENU", CENTER, 20);
  drawbutton1();
  drawbutton2();
  drawback();
  drawnext();
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
}


void drawoptions()
{
  myGLCD.setFont(BigFont);
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRoundRect(20, 70, 300, 120);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.setColor(255, 255, 255);
  myGLCD.print("OPTIONS", CENTER, 90);
}


void drawarm()
{
  myGLCD.setFont(BigFont);
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRoundRect(20, 140, 300, 190);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.setColor(255, 255, 255);
  myGLCD.print("ARM", CENTER, 160);
}


void printmonth(int i)
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.setFont(BigFont);
  if (i == 1)
  {
    myGLCD.print("JANUARY", 95, 100);
  }

  if (i == 2)
  {
    myGLCD.print("FEBRUARY", 95, 100);
  }

  if (i == 3)
  {
    myGLCD.print("MARCH", 95, 100);
  }

  if (i == 4)
  {
    myGLCD.print("APRIL", 95, 100);
  }

  if (i == 5)
  {
    myGLCD.print("MAY", 70, 100);
  }

  if (i == 6)
  {
    myGLCD.print("JUNE", 95, 100);
  }

  if (i == 7)
  {
    myGLCD.print("JULY", 95, 100);
  }

  if (i == 8)
  {
    myGLCD.print("AUGUST", 95, 100);
  }

  if (i == 9)
  {
    myGLCD.print("SEPTEMBER", 95, 100);
  }

  if (i == 10)
  {
    myGLCD.print("OCTOBER", 95, 100);
  }

  if (i == 11)
  {
    myGLCD.print("NOVEMBER", 95, 100);
  }

  if (i == 12)
  {
    myGLCD.print("DECEMBER", 95, 100);
  }
}



//int updatedate(int d, int m, int y)
//{
//  if (y % 4 == 0)//DISEKTO ETOS
//  {
//    if ((m >= 0) && (m <= 13))
//  {
//    if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 ||  m == 12)
//      {
//        if ((d >= 0) && (d <= 32))
//        {
//          if (d == 0)
//          {
//            d = 31;
//          }
//
//          if (d == 32)
//          {
//            d = 1;
//          }
//        }
//      }
//    }
//  }//DISEKTO ETOS END
//}



int armupdate(int i, int armlength)
{
  if (armlength < 4)
  {

    if (armlength == 0)
    {
      arminput[0] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(arminput[0], 100, 185); //+35 gia kathe noumero meta
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return arminput[0];
    }

    if (armlength == 1)
    {
      arminput[1] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(arminput[1], 135, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return arminput[1];
    }

    if (armlength == 2)
    {
      arminput[2] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(arminput[2], 170, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return arminput[2];
    }

    if (armlength == 3)
    {
      arminput[3] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(arminput[3], 205, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return arminput[3];
    }

  }

}



int autoarmupdate(int i, int timelength)
{
  if (timelength < 5)
  {
    if (timelength == 1)
    {
      timeinput[0] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(timeinput[0], 100, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return timeinput[0];
    }

    if (timelength == 2)
    {
      timeinput[1] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(timeinput[1], 135, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return timeinput[1];
    }

    if (timelength == 3)
    {
      timeinput[2] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(timeinput[2], 170, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return timeinput[2];
    }

    if (timelength == 4)
    {
      timeinput[3] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(timeinput[3], 205, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return timeinput[3];
    }
  }
}



int autoupdate(int i, int autolength)
{
  if (autolength < 5)
  {

    if (autolength == 0)
    {
      autoinput[0] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(autoinput[0], 100, 185); //+35 gia kathe noumero meta
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return autoinput[0];
    }

    if (autolength == 1)
    {
      autoinput[1] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(autoinput[1], 135, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return autoinput[1];
    }

    if (autolength == 2)
    {
      autoinput[2] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(autoinput[2], 170, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return autoinput[2];
    }

    if (autolength == 3)
    {
      autoinput[3] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(autoinput[3], 205, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return autoinput[3];
    }

    if (autolength == 4)
    {
      autoinput[4] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(autoinput[4], 240, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return autoinput[4];
    }

    if (autolength == 5)
    {
      autoinput[5] = i;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(autoinput[5], 275, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return autoinput[5];
    }

  }

}




int manualupdate(int i, int manuallength)
{
  if (manuallength < 6)
  {

    if (manuallength == 0)
    {
      manualinput[0] = i;
      //manuallength++;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(manualinput[0], 100, 185); //+35 gia kathe noumero meta
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return manualinput[0];

    }

    if (manuallength == 1)
    {
      manualinput[1] = i;
      //manuallength++;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(manualinput[1], 135, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return manualinput[1];
    }

    if (manuallength == 2)
    {
      manualinput[2] = i;
      //manuallength++;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(manualinput[2], 170, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return manualinput[2];
    }

    if (manuallength == 3)
    {
      manualinput[3] = i;
      //manuallength++;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(manualinput[3], 205, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return manualinput[3];
    }

    if (manuallength == 4)
    {
      manualinput[4] = i;
      //manuallength++;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(manualinput[4], 240, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return manualinput[4];
    }

    if (manuallength == 5)
    {
      manualinput[5] = i;
      //manuallength++;
      myGLCD.setColor(255, 0, 0);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.printNumI(manualinput[5], 275, 185);
      digitalWrite(buzzerpin, HIGH);
      delay(50);
      digitalWrite(buzzerpin, LOW);
      return manualinput[5];
    }

  }

}

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_EXTREME);
  pinMode(buzzerpin, OUTPUT);
  pinMode(systarm, OUTPUT);
  pinMode(serenapin, OUTPUT);
  digitalWrite(buzzerpin, HIGH);
  delay(1000);
  digitalWrite(buzzerpin, LOW);
  title();

  drawoptions();
  drawarm();

}

void loop()
{
  while (true)
  {
mainmenu:
    if (myTouch.dataAvailable())
    {
      myTouch.read();
      x = myTouch.getX();
      y = myTouch.getY();

      //OPTIONS BUTTON
      if ((x >= 20) && (x <= 300) && (y >= 70) && (y <= 120))
      {
options:
        optionsmenu();
        myGLCD.setBackColor(192, 192, 192);
        myGLCD.setColor(0, 0, 255);
        myGLCD.print("SET MANUAL-ARM PASSWORD", CENTER, 73);
        myGLCD.print("SET ARM PASSWORD", CENTER, 133);
        digitalWrite(buzzerpin, HIGH);
        delay(50);
        digitalWrite(buzzerpin, LOW);
        while (true)
        {
          if (myTouch.dataAvailable())
          {
            myTouch.read();
            x = myTouch.getX();
            y = myTouch.getY();

            //SET MANUAL PASSWORD BUTTON
            if ((x >= 20) && (x <= 300) && (y >= 60) && (y <= 100))
            {
              title();
              myGLCD.setBackColor(0, 0, 0);
              myGLCD.setColor(255, 0, 0);
              myGLCD.print("ENTER 6-DIGIT PASSWORD", CENTER, 119);
              drawback();
              drawnext();
              digitalWrite(buzzerpin, HIGH);
              delay(50);
              digitalWrite(buzzerpin, LOW);
              while (true)
              {
                if (myTouch.dataAvailable())
                {
                  myTouch.read();
                  x = myTouch.getX();
                  y = myTouch.getY();

                  if ((x >= 20) && (x <= 150) && (y >= 180) && (y <= 210))
                  {
                    digitalWrite(buzzerpin, HIGH);
                    delay(50);
                    digitalWrite(buzzerpin, LOW);
                    goto options;
                  }

                  if ((x >= 170) && (x <= 300) && (y >= 180) && (y <= 210))
                    //BUTTON MENU
                  {
                    for (int o = 0; o < 6; o++)
                    {
                      manualinput[o] = 0;
                    }
passinput:
                    int buf = 0;
                    myGLCD.setFont(SmallFont);
                    myGLCD.setColor(255, 255, 255);
                    myGLCD.drawLine(0, 14, 319, 14);
                    myGLCD.setColor(255, 255, 255);
                    drawbuttons();
                    digitalWrite(buzzerpin, HIGH);
                    delay(50);
                    digitalWrite(buzzerpin, LOW);
                    myGLCD.setFont(SevenSegNumFont);
                    myGLCD.setBackColor(0, 0, 0);


                    //akolouthei to while(true) & drawbuttons (TICK!)
                    while (true)
                    {
                      if (myTouch.dataAvailable())
                      {
                        myTouch.read();
                        x = myTouch.getX();
                        y = myTouch.getY();

                        //BUTTONS 1-3
                        if ((y >= 15) && (y <= 55))
                        {
                          if ((x >= 20) && (x <= 60)) //1
                          {
                            manualupdate(1, buf);
                            buf++;
                            delay(85);
                          }

                          if ((x >= 80) && (x <= 120)) //2
                          {
                            manualupdate(2, buf);
                            buf++;
                            delay(85);
                          }

                          if ((x >= 140) && (x <= 180)) //3
                          {
                            manualupdate(3, buf);
                            buf++;
                            delay(85);
                          }
                        }//BUTTONS 1-3 END


                        if ((y >= 70) && (y <= 110)) //BUTTONS 4-6
                        {
                          if ((x >= 20) && (x <= 60)) //4
                          {
                            manualupdate(4, buf);
                            buf++;
                            delay(85);
                          }

                          if ((x >= 80) && (x <= 120)) //5
                          {
                            manualupdate(5, buf);
                            buf++;
                            delay(85);
                          }

                          if ((x >= 140) && (x <= 180)) //6
                          {
                            manualupdate(6, buf);
                            buf++;
                            delay(85);
                          }
                        }//BUTTONS 4-6 END


                        if ((y >= 125) && (y <= 165)) //BUTTONS 7-9
                        {
                          if ((x >= 20) && (x <= 60)) //7
                          {
                            manualupdate(7, buf);
                            buf++;
                            delay(85);
                          }

                          if ((x >= 80) && (x <= 120)) //8
                          {
                            manualupdate(8, buf);
                            buf++;
                            delay(85);
                          }

                          if ((x >= 140) && (x <= 180)) //9
                          {
                            manualupdate(9, buf);
                            buf++;
                            delay(85);
                          }
                        }//BUTTONS 7-9 END

                        if ((x >= 20) && (x <= 80) && (y >= 175) && (y <= 205)) //0
                        {
                          manualupdate(0, buf);
                          buf++;
                          delay(85);
                        }

                        if ((x >= 190) && (x <= 290) && (y >= 70) && (y <= 110)) //OK BUTTON
                        {
                          bool flag = true;
                          for (int t = 0; t < 6; t++)
                          {
                            if (manualinput[t] != manualpass[t])
                            {
                              flag = false;
                            }
                          }

                          if (flag == true) //swstos kwdikos
                          {
                            for (int i = 0 ; i < 6; i++)
                            {
                              manualinput[i] = 0;
                            }
                            myGLCD.clrScr();
                            myGLCD.setFont(BigFont);
                            myGLCD.print("PASS OK!" , CENTER , 100);
                            digitalWrite(buzzerpin, HIGH);
                            delay(50);
                            digitalWrite(buzzerpin, LOW);
                            delay(2000);
                            title();
                            myGLCD.setBackColor(0, 0, 0);
                            myGLCD.setColor(255, 0, 0);
                            myGLCD.print("ENTER NEW PASSWORD", CENTER, 119);
                            drawback();
                            drawnext();
                            while (true)
                            {
                              if (myTouch.dataAvailable())
                              {
                                myTouch.read();
                                x = myTouch.getX();
                                y = myTouch.getY();

                                int buf = 0;

                                //EISAGWGH NEOU KWDIKOU
                                if ((x >= 170) && (x <= 300) && (y >= 180) && (y <= 210))
                                {
newmanpassinput:
                                  myGLCD.setFont(SmallFont);
                                  myGLCD.setColor(255, 255, 255);
                                  myGLCD.drawLine(0, 14, 319, 14);
                                  myGLCD.setColor(255, 255, 255);
                                  drawbuttons();
                                  digitalWrite(buzzerpin, HIGH);
                                  delay(50);
                                  digitalWrite(buzzerpin, LOW);
                                  myGLCD.setFont(SevenSegNumFont);
                                  myGLCD.setBackColor(0, 0, 0);

                                  while (true)
                                  {
                                    if (myTouch.dataAvailable())
                                    {
                                      myTouch.read();
                                      x = myTouch.getX();
                                      y = myTouch.getY();

                                      //BUTTONS 1-3
                                      if ((y >= 15) && (y <= 55))
                                      {
                                        if ((x >= 20) && (x <= 60)) //1
                                        {
                                          manualupdate(1, buf);
                                          buf++;
                                          delay(85);
                                        }

                                        if ((x >= 80) && (x <= 120)) //2
                                        {
                                          manualupdate(2, buf);
                                          buf++;
                                          delay(85);
                                        }

                                        if ((x >= 140) && (x <= 180)) //3
                                        {
                                          manualupdate(3, buf);
                                          buf++;
                                          delay(85);
                                        }
                                      }//BUTTONS 1-3 END


                                      if ((y >= 70) && (y <= 110)) //BUTTONS 4-6
                                      {
                                        if ((x >= 20) && (x <= 60)) //4
                                        {
                                          manualupdate(4, buf);
                                          buf++;
                                          delay(85);
                                        }

                                        if ((x >= 80) && (x <= 120)) //5
                                        {
                                          manualupdate(5, buf);
                                          buf++;
                                          delay(85);
                                        }

                                        if ((x >= 140) && (x <= 180)) //6
                                        {
                                          manualupdate(6, buf);
                                          buf++;
                                          delay(85);
                                        }
                                      }//BUTTONS 4-6 END


                                      if ((y >= 125) && (y <= 165)) //BUTTONS 7-9
                                      {
                                        if ((x >= 20) && (x <= 60)) //7
                                        {
                                          manualupdate(7, buf);
                                          buf++;
                                          delay(85);
                                        }

                                        if ((x >= 80) && (x <= 120)) //8
                                        {
                                          manualupdate(8, buf);
                                          buf++;
                                          delay(85);
                                        }

                                        if ((x >= 140) && (x <= 180)) //9
                                        {
                                          manualupdate(9, buf);
                                          buf++;
                                          delay(85);
                                        }
                                      }//BUTTONS 7-9 END

                                      if ((x >= 20) && (x <= 80) && (y >= 175) && (y <= 205)) //0
                                      {
                                        manualupdate(0, buf);
                                        buf++;
                                        delay(85);
                                      }

                                      //EDW THA MPEI TO OK. THA RWTAW AN O KWDIKOS EINAI ENTAKSEI (2 KOUMPIA, YES & NO). AN "YES", TOTE THA EPISTREFEI STO ARXIKO MENOU, AN "NO" THA EPISTREFEI STHN EISAGWGH KWDIKOY
                                      if ((x >= 190) && (x <= 290) && (y >= 70) && (y <= 110))//NEW PASS OK BUTTON
                                      {
                                        buf = 0;
                                        myGLCD.clrScr();
                                        title();
...

This file has been truncated, please download it to see its full contents.

Credits

Michail Marinis

Michail Marinis

3 projects • 21 followers
Junior Software Engineer at ipQuants AG. Open to all critics, I'm trying to improve each and every day.
Thanks to Henning Carlsen.

Comments