Advertisement
pleasedontcode

GPSTime rev_17

Nov 2nd, 2023
114
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:12:18
  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. void displayTimeOnLCD(uint8_t hours, uint8_t minutes, uint8_t seconds);
  35. void performContactClosure();
  36.  
  37. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  38. const uint8_t contactClosure_PIN_D2 = 2;
  39.  
  40. /***** DEFINITION OF Software Serial *****/
  41. const uint8_t gpsSerial_PIN_SERIAL_TX_A1 = A1;
  42. const uint8_t gpsSerial_PIN_SERIAL_RX_A0 = A0;
  43. SoftwareSerial gpsSerial(gpsSerial_PIN_SERIAL_RX_A0, gpsSerial_PIN_SERIAL_TX_A1);
  44.  
  45. /***** DEFINITION OF I2C PINS *****/
  46. const uint8_t display_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  47. const uint8_t display_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  48. const uint8_t display_LCD1602I2C_I2C_SLAVE_ADDRESS = 39;
  49.  
  50. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  51. LiquidCrystal_I2C lcd(display_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2);
  52. char nmeaBuffer[100];
  53. MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
  54.  
  55. void setup()
  56. {
  57.   // put your setup code here, to run once:
  58.  
  59.   pinMode(contactClosure_PIN_D2, OUTPUT);
  60.  
  61.   gpsSerial.begin(9600);
  62.  
  63.   lcd.begin(16, 2);
  64.   lcd.setBacklight(LOW);
  65.  
  66.   // Add your code here for setup system requirement 1
  67.  
  68. }
  69.  
  70. void loop()
  71. {
  72.   // put your main code here, to run repeatedly:
  73.  
  74.   // Add your code here for system requirement 1
  75.  
  76. }
  77.  
  78. void displayTimeOnLCD(uint8_t hours, uint8_t minutes, uint8_t seconds)
  79. {
  80.   // Convert hours, minutes, seconds to String format
  81.   String timeString = String(hours) + ":" + String(minutes) + ":" + String(seconds);
  82.  
  83.   // Clear the LCD screen
  84.   lcd.clear();
  85.  
  86.   // Set cursor to the first column of the first row
  87.   lcd.setCursor(0, 0);
  88.  
  89.   // Print the time on LCD
  90.   lcd.print(timeString);
  91. }
  92.  
  93. void performContactClosure()
  94. {
  95.   // Activate contact closure for about 1 second
  96.   digitalWrite(contactClosure_PIN_D2, HIGH);
  97.   delay(1000);
  98.   digitalWrite(contactClosure_PIN_D2, LOW);
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement