I am having problems running large programs, including 2 small programs.
Firstly, it is the program of module ds1307.
Secondly, it is the program that collects data from GPS.
The problem is that I'm new to arduino. I don't know how to run every single program without fail.
Collect date data from 1 gps and 1 clock, send data to LCD. Here is the code and the PCB.
I hope everyone will help me so I can complete it.
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
TinyGPS gps;
SoftwareSerial uart_gps(0, 1);
SoftwareSerial ds1307(18 ,19);
int seconds;
int timeoffset = 7;
char daysOfTheWeek[7][12] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
void setup()
{
Serial.begin(115200); // Start the serial for debug
uart_gps.begin(9600); // Start the GPS receiver UART
ds1307.begin(9600);
lcd.begin(16,2); // Declare the LCD
lcd.print(" GPS clock"); // Welcome message
delay(1000); // Wai one sec
lcd.clear(); // Clear the LCD
rtc.adjust(DateTime(2019, 10, 8, 7, 57 ,0));
}
void loop()
{
{DateTime now = rtc.now();
lcd.setCursor(0, 0);
lcd.print("Time:");
lcd.print(now.hour());
lcd.print(':');
lcd.print(now.minute());
lcd.print(':');
lcd.print(now.second());
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.print(" ,");
lcd.print(now.day());
lcd.print('/');
lcd.print(now.month());
lcd.print('/');
lcd.print(now.year());
delay(1000);
}
{
while(uart_gps.available())
{
int c = uart_gps.read();
if(gps.encode(c))
{
getgps(gps);
}
}
}
}
void getgps(TinyGPS &gps)
{
int year;
float latitude, longitude;
byte month, day, hour, minute, second, hundredths;
gps.f_get_position(&latitude, &longitude);
gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths);
hour = hour + timeoffset;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Time: ");
if (hour <= 9)
{
lcd.print("0"); lcd.print(hour, DEC);
}
else
{
lcd.print(hour, DEC);
}
lcd.print(":");
if (minute <=9)
{
lcd.print("0"); lcd.print(minute, DEC);
}
else
{
lcd.print(minute, DEC);
}
lcd.print(":");
if (second <= 9)
{
lcd.print("0"); lcd.print(second, DEC);
}
else
{
lcd.print(second, DEC);
}
lcd.setCursor(0,1);
lcd.print("Date: ");
if (day <= 9)
{
lcd.print("0"); lcd.print(day, DEC);
}
else
{
lcd.print(day, DEC);
}
lcd.print("-");
if (month <= 9)
{
lcd.print(month, DEC);
}
else
{
lcd.print(month, DEC);
}
lcd.print("-"); lcd.print(year, DEC);
delay(2000);
lcd.clear();
lcd.print("Lat: "); lcd.print(latitude, DEC);
lcd.setCursor(0,1);
lcd.print("Lon: "); lcd.print(longitude, DEC);
delay(2000);
}