25 Kasım 2020 Çarşamba

Tarih saat Ayarlanabilir Örnek uygulama (ALINTI)

Tarih saat Ayarlanabilir Örnek uygulama (ALINTI)

 

#include <16F628A.h>

#use delay(internal=4MHz)

#define LCD_ENABLE_PIN PIN_B0

#define LCD_RS_PIN PIN_B1

#define LCD_RW_PIN PIN_B2

#define LCD_DATA4 PIN_B4

#define LCD_DATA5 PIN_B5

#define LCD_DATA6 PIN_B6

#define LCD_DATA7 PIN_B7

#define RTC_SCLK PIN_A7

#define RTC_IO   PIN_A6

#define RTC_RST  PIN_A0

#include <DS1302.C>

#include <lcd.c>

int hr,min,sec,gun,ay,yil,hg,a=1;

void main()

{

   rtc_init();


   lcd_init();


   while(TRUE)

   {

if(input(pin_b3)==0)

{

a++;

delay_ms(200);

}

if(a>=8)

{

a=1;

}

switch (a)

{

case 1:

rtc_get_time(hr,min,sec);

rtc_get_date(gun,ay,yil,hg);

printf(lcd_putc,"\fTime=%02d:%02d:%02d",hr,min,sec);

lcd_gotoxy(1,2);

printf(lcd_putc,"Date=%02d/%02d/20%02d",gun,ay,yil);

delay_ms(200);

break;

case 2:

rtc_get_time(hr,min,sec);

if(input(pin_a1)==0)

{

hr++;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

else if(input(pin_a2)==0)

{

hr--;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

if(hr>=24)

{

hr=0;

}

printf(lcd_putc,"\fTime=%02d:%02d:%02d",hr,min,sec);

lcd_gotoxy(1,2);

lcd_putc("set--->[hour]");

delay_ms(200);

break;

case 3:

rtc_get_time(hr,min,sec);

if(input(pin_a1)==0)

{

min++;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

else if(input(pin_a2)==0)

{

min--;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

if(min>=60)

{

min=0;

}

printf(lcd_putc,"\fTime=%02d:%02d:%02d",hr,min,sec);

lcd_gotoxy(1,2);

lcd_putc("set--->[minute]");

delay_ms(200);

break;

case 4:

rtc_get_date(gun,ay,yil,hg);

if(input(pin_a1)==0)

{

gun++;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

else if(input(pin_a2)==0)

{

gun--;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

if(gun>=32)

{

gun=1;

}

printf(lcd_putc,"\fDate=%02d/%02d/20%02d",gun,ay,yil);

lcd_gotoxy(1,2);

lcd_putc("set--->[day]");

delay_ms(200);

break;

case 5:

rtc_get_date(gun,ay,yil,hg);

if(input(pin_a1)==0)

{

ay++;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

else if(input(pin_a2)==0)

{

ay--;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

if(ay>=13)

{

ay=1;

}

printf(lcd_putc,"\fDate=%02d/%02d/20%02d",gun,ay,yil);

lcd_gotoxy(1,2);

lcd_putc("set--->[month]");

delay_ms(200);

break;

case 6:

rtc_get_date(gun,ay,yil,hg);

if(input(pin_a1)==0)

{

yil++;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

else if(input(pin_a2)==0)

{

yil--;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

if(yil>=100)

{

yil=0;

}

printf(lcd_putc,"\fDate=%02d/%02d/20%02d",gun,ay,yil);

lcd_gotoxy(1,2);

lcd_putc("set--->[year]");

delay_ms(200);

break;

case 7:

rtc_get_date(gun,ay,yil,hg);

if(input(pin_a1)==0)

{

hg++;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

else if(input(pin_a2)==0)

{

hg--;

rtc_set_datetime(gun,ay,yil,hg,hr,min);

delay_ms(200);

}

if(hg>=8)

{

hg=1;

}

printf(lcd_putc,"\fDay of week= %d",hg);

lcd_gotoxy(1,2);

lcd_putc("set=>1-mon/7-sun");

delay_ms(200);

break;

}

}

}



Hiç yorum yok:

Yorum Gönder

Her yorum bilgidir. Araştırmaya devam...