/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: Scanner
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2023-10-29 15:38:21
	- Source Code generated by: AlexWind

********* Pleasedontcode.com **********/
/****** DEFINITION OF LIBRARIES *****/
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <MicroNMEA.h>

/****** SYSTEM REQUIREMENT 1 *****/
/* Reads NMEA 8bit data from GPS module. Reads hours */
/* minutes, seconds, and Display h, m, s on LED */
/* display. When mins and secs are 00 00, contact */
/* closure for about 1 sec. */

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t enabler_PushButton_PIN_D3 = 3;

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t contactClosure_PIN_D2 = 2;

/***** DEFINITION OF Software Serial *****/
const uint8_t gpsSerial_PIN_SERIAL_TX_A1 = A1;
const uint8_t gpsSerial_PIN_SERIAL_RX_A0 = A0;
SoftwareSerial gpsSerial(gpsSerial_PIN_SERIAL_RX_A0, gpsSerial_PIN_SERIAL_TX_A1);

/***** DEFINITION OF I2C PINS *****/
const uint8_t led_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
const uint8_t led_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
const uint8_t led_LCD1602I2C_I2C_SLAVE_ADDRESS = 39;

/***** DEFINITION OF LCD OBJECT *****/
LiquidCrystal_I2C lcd(led_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2); // Adjust the number of columns and rows according to your LCD

// Variables to store minutes and seconds
int mins = 0;
int secs = 0;

void setup(void)
{
  // put your setup code here, to run once:

  pinMode(enabler_PushButton_PIN_D3, INPUT_PULLUP);

  pinMode(contactClosure_PIN_D2, OUTPUT);

  gpsSerial.begin(9600);

  lcd.begin(16, 2); // Initialize the LCD with the number of columns and rows
  lcd.backlight(); // Turn on the backlight of the LCD

}

void loop(void)
{
  // put your main code here, to run repeatedly:

  // Read NMEA data from GPS module
  if (gpsSerial.available())
  {
    char data = gpsSerial.read();
    // Process the NMEA data here
  }

  // Check if mins and secs are 00 00
  if (mins == 0 && secs == 0)
  {
    // Activate contact closure for about 1 second
    digitalWrite(contactClosure_PIN_D2, HIGH);
    delay(1000);
    digitalWrite(contactClosure_PIN_D2, LOW);
  }
}