Advertisement
pleasedontcode

Scanner rev_74

Nov 1st, 2023
84
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: Scanner
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-01 18:45:15
  15.     - Source Code generated by: AlexWind
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <SoftwareSerial.h>
  21. #include <Wire.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 LED */
  28. /* display. When mins and secs are 00 00, contact */
  29. /* closure for about 1 sec. */
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  36. const uint8_t enabler_PushButton_PIN_D3 = 3;
  37.  
  38. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  39. const uint8_t contactClosure_PIN_D2 = 2;
  40.  
  41. /***** DEFINITION OF Software Serial *****/
  42. const uint8_t gpsSerial_PIN_SERIAL_TX_A1 = A1;
  43. const uint8_t gpsSerial_PIN_SERIAL_RX_A0 = A0;
  44. SoftwareSerial gpsSerial(gpsSerial_PIN_SERIAL_RX_A0, gpsSerial_PIN_SERIAL_TX_A1);
  45.  
  46. /***** DEFINITION OF I2C PINS *****/
  47. const uint8_t led_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  48. const uint8_t led_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  49. const uint8_t led_LCD1602I2C_I2C_SLAVE_ADDRESS = 39;
  50.  
  51. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  52. LiquidCrystal_I2C lcd(led_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2);
  53. char nmeaBuffer[100];
  54. MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
  55.  
  56. void setup(void)
  57. {
  58.   // put your setup code here, to run once:
  59.  
  60.   pinMode(enabler_PushButton_PIN_D3, INPUT_PULLUP);
  61.  
  62.   pinMode(contactClosure_PIN_D2, OUTPUT);
  63.  
  64.   gpsSerial.begin(9600);
  65.  
  66.   lcd.begin(16, 2);
  67.   lcd.backlight();
  68. }
  69.  
  70. void loop(void)
  71. {
  72.   // put your main code here, to run repeatedly:
  73.  
  74.   // Read NMEA data from GPS module
  75.   while (gpsSerial.available())
  76.   {
  77.     char c = gpsSerial.read();
  78.     nmea.process(c);
  79.   }
  80.  
  81.   // Check if the time is 00:00
  82.   if (nmea.getHour() == 0 && nmea.getMinute() == 0)
  83.   {
  84.     // Activate contact closure for 1 second
  85.     digitalWrite(contactClosure_PIN_D2, HIGH);
  86.     delay(1000);
  87.     digitalWrite(contactClosure_PIN_D2, LOW);
  88.   }
  89.  
  90.   // Display hours, minutes, and seconds on the LCD display
  91.   lcd.setCursor(0, 0);
  92.   lcd.print("Time: ");
  93.   lcd.print(nmea.getHour());
  94.   lcd.print(":");
  95.   lcd.print(nmea.getMinute());
  96.   lcd.print(":");
  97.   lcd.print(nmea.getSecond());
  98.  
  99.   // Clear the LCD display after 1 second
  100.   delay(1000);
  101.   lcd.clear();
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement