Advertisement
pleasedontcode

GPSTime rev_19

Nov 2nd, 2023
137
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-02 23:21:33
  15.     - Source Code generated by: Francesco Alessandro
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <Wire.h>
  21. #include <SoftwareSerial.h>
  22. #include <LiquidCrystal_I2C.h>
  23. #include <MicroNMEA.h>
  24.  
  25. /****** SYSTEM REQUIREMENT 1 *****/
  26. /* Reads NMEA 8bit data from GPS module. Reads hours */
  27. /* minutes, seconds and Display h, m, s on 6x 7seg */
  28. /* LED display. When mins and secs are 00 00, */
  29. /* contact closure for about 1 sec. */
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  36. const uint8_t contactClosure_PIN_D2 = 2;
  37.  
  38. /***** DEFINITION OF Software Serial *****/
  39. const uint8_t gpsSerial_PIN_SERIAL_TX_A1 = A1;
  40. const uint8_t gpsSerial_PIN_SERIAL_RX_A0 = A0;
  41. SoftwareSerial gpsSerial(gpsSerial_PIN_SERIAL_RX_A0, gpsSerial_PIN_SERIAL_TX_A1);
  42.  
  43. /***** DEFINITION OF I2C PINS *****/
  44. const uint8_t display_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  45. const uint8_t display_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  46. const uint8_t display_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27;
  47.  
  48. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  49. LiquidCrystal_I2C lcd(display_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2);
  50. char nmeaBuffer[100];
  51. MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
  52.  
  53. void setup(void)
  54. {
  55.   // put your setup code here, to run once:
  56.  
  57.   pinMode(contactClosure_PIN_D2, OUTPUT);
  58.  
  59.   gpsSerial.begin(9600);
  60.  
  61.   lcd.begin(16, 2);
  62.   lcd.backlight();
  63. }
  64.  
  65. void loop(void)
  66. {
  67.   // put your main code here, to run repeatedly:
  68.  
  69.   if (gpsSerial.available())
  70.   {
  71.     while (gpsSerial.available() > 0)
  72.     {
  73.       char c = gpsSerial.read();
  74.       nmea.process(c);
  75.     }
  76.  
  77.     if (nmea.getHour() == 0 && nmea.getMinute() == 0 && nmea.getSecond() == 0)
  78.     {
  79.       digitalWrite(contactClosure_PIN_D2, HIGH);
  80.       delay(1000);
  81.       digitalWrite(contactClosure_PIN_D2, LOW);
  82.     }
  83.  
  84.     lcd.clear();
  85.     lcd.setCursor(0, 0);
  86.     lcd.print("Time: ");
  87.     lcd.print(nmea.getHour());
  88.     lcd.print(":");
  89.     lcd.print(nmea.getMinute());
  90.     lcd.print(":");
  91.     lcd.print(nmea.getSecond());
  92.   }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement