: 11/08/2014
Chip type
Program type
: ATmega16
: Application
: Small
: 0
: 256
*****************************************************/
void jam_digital()
{
if (detik==60)
{
lcd_clear();
detik=0;
menit++;
}
if (menit==60)
{
lcd_clear();
menit=0;
jam++;
}
if (jam==24)
{
lcd_clear();
jam=0;
}
}
void tampil_lcd()
{
lcd_gotoxy(0,0);
lcd_putsf(" Apartment 57");
itoa(jam,temp); //menampilkan JAM di LCD
lcd_gotoxy(0,1);
lcd_puts(temp);
lcd_gotoxy(2,1); //menampilkan :
lcd_putsf(":");
itoa(menit,temp); //menampilkan MENIT di LCD
lcd_gotoxy(3,1);
lcd_puts(temp);
lcd_gotoxy(5,1); //menampilkan :
lcd_putsf(":");
lcd_clear();
if (jam<0)
{
jam=0;
}
}
}
}
}
if (PIND.0==0 && indeks==5)
{
delay_ms(300);
indeks=4;
while (PIND.0==1 && indeks==4)
{
tampil_lcd();
if (PIND.1==0)
{
delay_ms(300);
jam=jam+1;
if (jam>=24)
{
jam=23;
}
}
if (PIND.2==0)
{
delay_ms(300);
jam=jam-1;
if (jam<=9)
{
lcd_clear();
if (jam<0)
{
jam=0;
}
}
}
}
}
if (PIND.0==0 && indeks==4)
{
delay_ms(300);
indeks=3;
while (PIND.0==1 && indeks==3)
{
tampil_lcd();
if (PIND.1==0)
{
delay_ms(300);
menit=menit+10;
if (menit>=60)
{
menit=59;
}
}
if (PIND.2==0)
{
delay_ms(300);
menit=menit-10;
if (menit<=9)
{
lcd_clear();
if (menit<0)
{
menit=0;
}
}
}
}
}
if (PIND.0==0 && indeks==3)
{
delay_ms(300);
indeks=2;
while (PIND.0==1 && indeks==2)
{
tampil_lcd();
if (PIND.1==0)
{
delay_ms(300);
menit=menit+1;
if (menit>=60)
{
menit=59;
}
}
if (PIND.2==0)
{
delay_ms(300);
menit=menit-1;
if (menit<=9)
{
lcd_clear();
if (menit<0)
{
menit=0;
}
}
}
}
}
if (PIND.0==0 && indeks==2)
{
delay_ms(300);
indeks=1;
while (PIND.0==1 && indeks==1)
{
tampil_lcd();
if (PIND.1==0)
{
delay_ms(300);
detik=detik+1;
if (detik>=60)
{
detik=59;
}
}
if (PIND.2==0)
{
delay_ms(300);
detik=detik-1;
if (detik<=9)
{
lcd_clear();
if (detik<0)
{
detik=0;
}
}
}
}
}
if (PIND.0==0 && indeks==1)
{
delay_ms(300);
indeks=0;
while (PIND.0==1 && indeks==0)
{
tampil_lcd();
if (PIND.1==0)
{
delay_ms(300);
detik=detik+1;
if (detik>=60)
{
detik=59;
}
}
if (PIND.2==0)
{
delay_ms(300);
detik=detik-1;
if (detik<=9)
{
lcd_clear();
if (detik<0)
{
detik=0;
}
}
}
}
indeks=6;
TIMSK=0x04; //MEMULAI LAGI TIMER
delay_ms(450);
}
}
void baca_suhu()
{
suhu=(float)adc_suhu*500/1023;//perhitungan suhu menggunakan
LM35
}
// ADC initialization
// ADC Clock frequency: 750,000 kHz
// ADC Voltage Reference: AREF pin
// ADC Auto Trigger Source: ADC Stopped
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x84;
// SPI initialization
// SPI disabled
SPCR=0x00;
// TWI initialization
// TWI disabled
TWCR=0x00;
// Alphanumeric LCD initialization
// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTC Bit 0
// RD - PORTC Bit 1
// EN - PORTC Bit 2
// D4 - PORTC Bit 4
// D5 - PORTC Bit 5
// D6 - PORTC Bit 6
// D7 - PORTC Bit 7
// Characters/line: 16
lcd_init(16);
// Global enable interrupts
#asm("sei")
while (1)
{
// Place your code here
baca_suhu();
jam_digital();
tampil_lcd();
set_jam();
}
}
Selamat Mencoba
Good Luck !!!