politxillo:
Hi, i've seen you replied to my post about the GPS clock,
i've tried to make a simple clock with the arduino without the RTC, it works but when hundredths rise above 100, the counter jumps on seconds, and the clock crashes, could you take a look to the code please? thanks!#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>//incluimos SoftwareSerial
#define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
SoftwareSerial serialgps(4,3);//Declaramos el pin 4 Tx y 3 Rx
unsigned long timeNow = 0;
unsigned long timeLast = 0;
//Time start Settings:
int startingHour = 12; // set your starting hour here, not below at int hour. This ensures accurate daily correction of time
int hundredths = 0;
int seconds = 0;
int minutes = 59;
int hours = startingHour;
void setup() {
lcd.begin(20,4);//Iniciamos el puerto serie
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home ();
void loop() {
// put your main code here, to run repeatedly:
timeNow = millis()/10;
hundredths = timeNow;
if (hundredths >= 100) {
hundredths = 0;
seconds = seconds + 1;
}
if (seconds == 60) {
seconds=0;
minutes = minutes + 1;
}
if (minutes == 60){
minutes = 0;
hours = hours + 1;
}
lcd.setCursor(0,0);
lcd.print(hours);
lcd.print(":");
lcd.print(minutes);
lcd.print(":");
lcd.print(seconds);
lcd.print(":");
lcd.print(hundredths);
}
Don't do it in pm, so that other have a change to know what is happening.
Why don't you use the Time library that I show you?
It have all the function
hour(); // The hour now (0-23)
minute(); // The minute now (0-59)
second(); // The second now (0-59)
day(); // The day now (1-31)
weekday(); // Day of the week, Sunday is day 1
month(); // The month now (1-12)
year(); // The full four digit year: (2009,
// 2010 etc)