CCCPaste

GPSTime rev_117

/********* 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: GPSTime
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2023-11-25 00:00:33
	- Source Code generated by: Francesco Alessandro

********* Pleasedontcode.com **********/
/****** DEFINITION OF LIBRARIES *****/
#include 
#include 
#include 
#include 
#include 

/****** SYSTEM REQUIREMENT 1 *****/
/* Reads hour, minutes and seconds from GPS */
/* module using MicroNMEA library. Display hours, */
/* minutes and seconds on 6x 7seg 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 OUTPUT PINS *****/
const uint8_t contactClosure_PIN_D7 = 7;

/***** DEFINITION OF Software Serial *****/
const uint8_t NEO_6M_GPS_module_PIN_SERIAL_TX_A0 = A0;
const uint8_t NEO_6M_GPS_module_PIN_SERIAL_RX_A1 = A1;
SoftwareSerial NEO_6M_GPS_module(NEO_6M_GPS_module_PIN_SERIAL_RX_A1, NEO_6M_GPS_module_PIN_SERIAL_TX_A0);

/***** DEFINITION OF I2C PINS *****/
const uint8_t lcd_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
const uint8_t lcd_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
const uint8_t lcd_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
LiquidCrystal_I2C lcd(lcd_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2);
MicroNMEA nmea;

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

  pinMode(contactClosure_PIN_D7, OUTPUT);

  NEO_6M_GPS_module.begin(9600);

  lcd.begin(16, 2);
  lcd.print("GPS Time Display");

}

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

  // Read time from GPS module
  if (NEO_6M_GPS_module.available())
  {
    char c = NEO_6M_GPS_module.read();
    // Process the received character using MicroNMEA library
    // and extract the time information
    if (nmea.process(c))
    {
      if (nmea.getHour() == 0 && nmea.getMinute() == 0 && nmea.getSecond() == 0)
      {
        // Activate contact closure for 1 second
        digitalWrite(contactClosure_PIN_D7, HIGH);
        delay(1000);
        digitalWrite(contactClosure_PIN_D7, LOW);
      }
      else
      {
        // Display the time on the LCD
        lcd.setCursor(0, 1);
        lcd.print(nmea.getHour());
        lcd.print(":");
        lcd.print(nmea.getMinute());
        lcd.print(":");
        lcd.print(nmea.getSecond());
      }
    }
  }
}