Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 7372800UL
- #include <avr/io.h>
- #include "lcd.h"
- #include <avr/interrupt.h>
- #include <string.h>
- uint8_t stotinke = 0;
- uint8_t sekunde = 0;
- uint8_t minute = 0;
- uint8_t sati = 0;
- void write2lcd()
- {
- char string[16];
- sprintf(string, "%.2d:%.2d:%.2d", sati, minute, sekunde);
- lcd_clrscr();
- lcd_gotoxy(2,1);
- lcd_puts(string);
- }
- ISR(TIMER0_COMP_vect)
- {
- stotinke++;
- if(stotinke == 100)
- {
- sekunde++;
- stotinke = 0;
- }
- if(sekunde == 60)
- {
- minute++;
- sekunde = 0;
- }
- if(minute == 60)
- {
- sati++;
- minute = 0;
- }
- if(sati == 24)
- {
- sati = 0;
- }
- write2lcd();
- }
- int main(void)
- {
- DDRD = _BV(4);
- TCCR1A = _BV(COM1B1) | _BV(WGM10);
- TCCR1B = _BV(WGM12);
- OCR1B = 50;
- TCCR0 = _BV(WGM01) | _BV(CS00) | _BV(CS02);
- OCR0 = 71;
- TIMSK = _BV(OCIE0);
- sei();
- lcd_init(LCD_DISP_ON);
- lcd_clrscr();
- while (1)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement