Advertisement
pleasedontcode

GPSTime rev_117

Nov 24th, 2023
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: GPSTime
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-25 00:00:33
  15.     - Source Code generated by: Francesco Alessandro
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <SoftwareSerial.h>
  21. #include <Wire.h>
  22. #include <MicroNMEA.h>
  23. #include <LiquidCrystal_I2C.h>
  24.  
  25. /****** SYSTEM REQUIREMENT 1 *****/
  26. /* Reads hour, minutes and seconds from GPS */
  27. /* module using MicroNMEA library. Display hours, */
  28. /* minutes and seconds on 6x 7seg LED display. When */
  29. /* mins and secs are 00 00, contact closure for about */
  30. /* 1 sec. */
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35.  
  36. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  37. const uint8_t contactClosure_PIN_D7 = 7;
  38.  
  39. /***** DEFINITION OF Software Serial *****/
  40. const uint8_t NEO_6M_GPS_module_PIN_SERIAL_TX_A0 = A0;
  41. const uint8_t NEO_6M_GPS_module_PIN_SERIAL_RX_A1 = A1;
  42. SoftwareSerial NEO_6M_GPS_module(NEO_6M_GPS_module_PIN_SERIAL_RX_A1, NEO_6M_GPS_module_PIN_SERIAL_TX_A0);
  43.  
  44. /***** DEFINITION OF I2C PINS *****/
  45. const uint8_t lcd_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  46. const uint8_t lcd_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  47. const uint8_t lcd_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27;
  48.  
  49. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  50. LiquidCrystal_I2C lcd(lcd_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2);
  51. MicroNMEA nmea;
  52.  
  53. void setup(void)
  54. {
  55.   // put your setup code here, to run once:
  56.  
  57.   pinMode(contactClosure_PIN_D7, OUTPUT);
  58.  
  59.   NEO_6M_GPS_module.begin(9600);
  60.  
  61.   lcd.begin(16, 2);
  62.   lcd.print("GPS Time Display");
  63.  
  64. }
  65.  
  66. void loop(void)
  67. {
  68.   // put your main code here, to run repeatedly:
  69.  
  70.   // Read time from GPS module
  71.   if (NEO_6M_GPS_module.available())
  72.   {
  73.     char c = NEO_6M_GPS_module.read();
  74.     // Process the received character using MicroNMEA library
  75.     // and extract the time information
  76.     if (nmea.process(c))
  77.     {
  78.       if (nmea.getHour() == 0 && nmea.getMinute() == 0 && nmea.getSecond() == 0)
  79.       {
  80.         // Activate contact closure for 1 second
  81.         digitalWrite(contactClosure_PIN_D7, HIGH);
  82.         delay(1000);
  83.         digitalWrite(contactClosure_PIN_D7, LOW);
  84.       }
  85.       else
  86.       {
  87.         // Display the time on the LCD
  88.         lcd.setCursor(0, 1);
  89.         lcd.print(nmea.getHour());
  90.         lcd.print(":");
  91.         lcd.print(nmea.getMinute());
  92.         lcd.print(":");
  93.         lcd.print(nmea.getSecond());
  94.       }
  95.     }
  96.   }
  97. }
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement