18f4550 ile oluşturulan saat devresi.
Detaylar sonra eklenecektir...
Kod mikroc ile yazılmıştır;
// Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
char dak=0;
char sn=0;
char saat;
int say=0;
char k_d[4];
char k_sn[4];
char k_s[4];
void interrupt(){
if (PIR1.TMR2IF){
say++;
TMR2=6;
PIR1.TMR2IF=0;
}
}
void init(){
ADCON1 |=0X0F;
CMCON |=7;
T2CON=0X05;
TMR2=6; // ön deger
INTCON.GIE=1;
INTCON.PEIE=1;
PIE1.TMR2IE=1;
Lcd_Init();
Lcd_cmd(_lcd_clear);
lcd_cmd(_lcd_cursor_off);
}
void main() {
init();
while(1){
if(say>=1000){
sn++;
if (sn>59){
sn=0;
dak++ ;
if(dak>59){
saat++;
dak=0;
if (saat=24){
saat=0;
}
}
}
say=0;
}
bytetostr(dak,k_d);
bytetostr(sn,k_sn);
bytetostr(saat,k_s);
lcd_out(1,1,k_s);
lcd_out(1,4,":");
lcd_out(1,5,k_d);
lcd_out(1,8,":");
lcd_out(1,9,k_sn);
}
}
Hiç yorum yok:
Yorum Gönder