پاسخ : مدار ساعت با سون سگمنت
من یه مدار دارم ولی منظور شما رو ندونستم بیشتر توضیح بدید اگه مناسب بود بذارم.
من یه مدار دارم ولی منظور شما رو ندونستم بیشتر توضیح بدید اگه مناسب بود بذارم.
/* include the DS1307 functions for bit-banged I2C The I2C bus connections and bit rate must be specified in the Project|Configure|C Compiler|Libraries|I2C menu */ #include <ds1307.h> /* include the LCD Functions The connections must be specified in the Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu */ #include <alcd.h> /* include the prototype for sprintf */ #include <stdio.h> /* include the prototypes for the delay functions */ #include <delay.h> char display_buffer[17]; /* LCD display buffer for 1 line */ void main(void) { unsigned char hour,min,sec,week_day,day,month,year; /* initialize the LCD, 2 rows by 16 columns */ lcd_init(16); /* initialize the bit-banged I2C functions */ i2c_init(); /* initialize the RTC square wave output is disabled SQW/OUT has logic state 0 */ rtc_init(0,0,0); rtc_set_time(12,0,0); /* set time 12:00:00 */ rtc_set_date(2,1,2,11); /* set date Tuesday 1/02/2013 */ /* display the time and date continuously */ while (1) { /* read the time from the RTC */ rtc_get_time(&hour,&min,&sec); /* read the date from the RTC */ rtc_get_date(&week_day,&day,&month,&year); /* display the time on the LCD */ sprintf(display_buffer,"Time: %2d:%02d:%02d\n",hour,min,sec); lcd_clear(); lcd_puts(display_buffer); /* display the date on the LCD */ sprintf(display_buffer,"Date: %2d/%02d/%d",day,month, 2000+year); lcd_puts(display_buffer); delay_ms(500); /* 0.5 second delay */ } }
دیدگاه