Tuesday, July 9, 2013
Digital clock LCD with ATmega32 (Jam Digital dengan LCD ATmega32)
Kali ini, saya membuat rangakain elektronik jam digital dan tanggal menggunakan LCD (16x2) dengan otaknya adalah ATmega32. Rangkaian di atas adalah simulasi menggunakan software proteus.
===========================C code========================================
/*****************************************************
This program was produced by the
CodeWizardAVR V2.04.4a Advanced
Automatic Program Generator
© Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 7/9/2013
Author : Hambali
Company : Hamnoit production
Comments:
Chip type : ATmega32
Program type : Application
AVR Core Clock frequency: 12.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
*****************************************************/
#include <mega32.h>
#include <delay.h>
#include <stdio.h>
// I2C Bus functions
#asm
.equ __i2c_port=0x15 ;PORTC
.equ __sda_bit=1
.equ __scl_bit=0
#endasm
#include <i2c.h>
#include <ds1307.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x18 ;PORTB
#endasm
#include <lcd.h>
char buf[33];
unsigned char dd;
unsigned char mm;
unsigned char yy;
unsigned char s;
unsigned char m;
unsigned char h;
void main(void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0x00;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
MCUCR=0x00;
MCUCSR=0x00;
TIMSK=0x00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
ACSR=0x80;
SFIOR=0x00;
// I2C Bus initialization
i2c_init();
// DS1307 Real Time Clock initialization
// Square wave output on pin SQW/OUT: Off
// SQW/OUT pin state: 0
rtc_init(0,0,0);
lcd_init(16);
lcd_clear();
lcd_gotoxy(0,0);
lcd_putsf(" DigitaL Clock"); //dapat dirubah sesuai keinginan
lcd_gotoxy(0,1);
lcd_putsf("Hamnoit.blogspot.com"); //dapat dirubah sesuai keinginan
printf("Jam Digital dengan CodeVision AVR\r"); //dapat dirubah sesuai keinginan
delay_ms(2000);
rtc_set_time(11,12,00); //setting jam, (ketik jam yg ingin di tampilkan)
rtc_set_date(02,03,12); //setting tanggal, (ketik tanggal yg ingin di tampilkan pertama kali
while (1)
{
rtc_get_time(&h,&m,&s);
rtc_get_date(&dd,&mm,&yy);
lcd_gotoxy(0,0);
sprintf(buf,"Tanggal:%02u/%02u/%02u",dd,mm,yy);
lcd_puts(buf);
lcd_gotoxy(0,1);
sprintf(buf,"Waktu :%02u:%02u:%02u",h,m,s);
lcd_puts(buf);
printf("Tanggal: %02u:%02u:%02u \r",dd,mm,yy);
printf("Waktu : %02u:%02u:%02u \r",h,m,s);
delay_ms(1000);
};
}
=======================================================================
FILE PROJECT :
Digital clock LCD with ATmega32
PASSWORD :
hamnoit
Subscribe to:
Post Comments (Atom)
mohon infonya, stlh say build tnyata ad yg eror pd bagian printf, cr mengatasinya bgman
ReplyDeletemohon infonya juga, saya udh di build tap ad eror 2,di bagian rtc_get_date,mohon jawabannya d kirim email aj
ReplyDeleteudah bisa t mas gimana caranya
DeleteMas kalau atmega 32 saat digunakan untuk blink led delay 1000 ms tetapi tidak tepat sangat jauh dari nilai delay tsb knp ya mas
ReplyDelete