Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* 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-20 16:06: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 SoftwareSerial *****/ 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_SLAVE_ADDRESS = 39; /****** DEFINITION OF CLASS INSTANCES *****/ MicroNMEA nmea; // MicroNMEA class instance LiquidCrystal_I2C lcd(lcd_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2); // LiquidCrystal_I2C class instance void setup(void) { // Initialize contact closure pin as output pinMode(contactClosure_PIN_D7, OUTPUT); // Initialize software serial for GPS module NEO_6M_GPS_module.begin(9600); // Initialize LCD display lcd.begin(16, 2); lcd.backlight(); // Clear LCD display lcd.clear(); } void loop(void) { // Read GPS data if available while (NEO_6M_GPS_module.available()) { char c = NEO_6M_GPS_module.read(); nmea.process(c); } // Check for a valid GPS fix if (nmea.isValid()) { // Get hours, minutes, and seconds from GPS int hours = nmea.getHour(); int minutes = nmea.getMinute(); int seconds = nmea.getSecond(); // Display hours, minutes, and seconds on LCD lcd.setCursor(0, 0); lcd.print("Time: "); lcd.print(hours); lcd.print(":"); if (minutes < 10) { lcd.print("0"); } lcd.print(minutes); lcd.print(":"); if (seconds < 10) { lcd.print("0"); } lcd.print(seconds); // Check if minutes and seconds are zero if (minutes == 0 && seconds == 0) { // Activate contact closure for 1 second digitalWrite(contactClosure_PIN_D7, HIGH); delay(1000); digitalWrite(contactClosure_PIN_D7, LOW); } } else { // Display "No Fix" message on LCD lcd.setCursor(0, 0); lcd.print("No Fix"); } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)