Sript Jam Digital Tanpa RTC



Description: /Users/zoel/Desktop/Screen Shot 2017-01-16 at 9.46.40 AM.png




JAM DIGITAL TANPA RTC


/*Membuat Jam digital dengan Arduino Tanpa Hardware RTC
*24 July 2015
*www.boarduino.blogspot.com
*/

#include <Time.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
Serial.begin(9600);
lcd.begin(16,2);
setTime(00,55,00,24,7,14); //(Jam,Menit,Detik,Tanggal,Bulan,Tahun)
}

void loop(){
//Kalender Tahun 2015
if(day() >= 28 && month() == 2 && year() == 15){
  setTime(0,0,0,1,3,15); }
else if(day() >= 30 && month() == 4 && year() == 15){
  setTime(0,0,0,1,5,15); }
else if(day() >= 30 && month() == 6 && year() == 15){
  setTime(0,0,0,1,7,15); }
else if(day() >= 30 && month() == 9 && year() == 15){
  setTime(0,0,0,1,10,15); }
else if(day() >= 30 && month() == 11 && year() == 15){
  setTime(0,0,0,1,12,15); }

//Kalender Tahun 2016
else if(day() >= 29 && month() == 2 && year() == 16){
  setTime(0,0,0,1,3,16); }
else if(day() >= 30 && month() == 4 && year() == 16){
  setTime(0,0,0,1,5,16); }
else if(day() >= 30 && month() == 6 && year() == 16){
  setTime(0,0,0,1,7,16); }
else if(day() >= 30 && month() == 9 && year() == 16){
  setTime(0,0,0,1,10,16); }
else if(day() >= 30 && month() == 11 && year() == 16){
  setTime(0,0,0,1,12,16); }

//Kalender Tahun 2017
else if(day() >= 28 && month() == 2 && year() == 17){
  setTime(0,0,0,1,3,17); }
else if(day() >= 30 && month() == 4 && year() == 17){
  setTime(0,0,0,1,5,17); }
else if(day() >= 30 && month() == 6 && year() == 17){
  setTime(0,0,0,1,7,17); }
else if(day() >= 30 && month() == 9 && year() == 17){
  setTime(0,0,0,1,10,17); }
else if(day() >= 30 && month() == 11 && year() == 17){
  setTime(0,0,0,1,12,17); }

//Kelender Tahun 2018
else if(day() >= 28 && month() == 2 && year() == 18){
  setTime(0,0,0,1,3,18); }
else if(day() >= 30 && month() == 4 && year() == 18){
  setTime(0,0,0,1,5,18); }
else if(day() >= 30 && month() == 6 && year() == 18){
  setTime(0,0,0,1,7,18); }
else if(day() >= 30 && month() == 9 && year() == 18){
  setTime(0,0,0,1,10,18); }
else if(day() >= 30 && month() == 11 && year() == 18){
  setTime(0,0,0,1,12,18); }

//Kelender Tahun 2019
else if(day() >= 28 && month() == 2 && year() == 19){
  setTime(0,0,0,1,3,19); }
else if(day() >= 30 && month() == 4 && year() == 19){
  setTime(0,0,0,1,5,19); }
else if(day() >= 30 && month() == 6 && year() == 19){
  setTime(0,0,0,1,7,19); }
else if(day() >= 30 && month() == 9 && year() == 19){
  setTime(0,0,0,1,10,19); }
else if(day() >= 30 && month() == 11 && year() == 19){
  setTime(0,0,0,1,12,19); }

//Kelender Tahun 2020
else if(day() >= 29 && month() == 2 && year() == 20){
  setTime(0,0,0,1,3,20); }
else if(day() >= 30 && month() == 4 && year() == 20){
  setTime(0,0,0,1,5,20); }
else if(day() >= 30 && month() == 6 && year() == 20){
  setTime(0,0,0,1,7,20); }
else if(day() >= 30 && month() == 9 && year() == 20){
  setTime(0,0,0,1,10,20); }
else if(day() >= 30 && month() == 11 && year() == 20){
  setTime(0,0,0,1,12,20); }

else if(hour() == 0 && minute() == 0 && second() == 0){
  lcd.clear();
  lcd.print ("Date: ");
  printkurangdarinol(day());
  lcd.print(":");
  printkurangdarinol(month());
  lcd.print(":");
  printkurangdarinol(year());

  lcd.setCursor(0,1);
  lcd.print("Time:  ");
  printkurangdarinol(hour());
  lcd.print(":");
  printkurangdarinol(minute());
  lcd.print(":");
  printkurangdarinol(second());
}

lcd.print ("Date: ");
printkurangdarinol(day());
lcd.print(":");
printkurangdarinol(month());
lcd.print(":");
printkurangdarinol(year());

lcd.setCursor(0,1);
lcd.print("Time:  ");
printkurangdarinol(hour());
lcd.print(":");
printkurangdarinol(minute());
lcd.print(":");
printkurangdarinol(second());
delay (1000);
}

void printkurangdarinol(int data){
  if (data >= 0 && data < 10){
    lcd.write('0');
  }
  lcd.print(data);
}

Komentar

Postingan populer dari blog ini

Program Arduino Sensor Suhu

Penjelasan tentang Dawn Of Net