You are on page 1of 10

/*****************************************************

This program was produced by the
CodeWizardAVR V2.05.3 Standard
Automatic Program Generator
© Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date
: 10/21/2013
Author : Sh.mukti
Company : Jangan gunakan software bajakan!
Comments:
Chip type
: ATmega16
Program type
: Application
AVR Core Clock frequency: 12.000000 MHz
Memory model
: Small
External RAM size
: 0
Data Stack size
: 256
*****************************************************/
#include <mega16.h>
#include <stdio.h>
#include <delay.h>
#define
#define
#define
#define
#define
#define
#define
#define

led1
led2
led3
led4
led5
led6
led7
led8

PORTD.0
PORTD.1
PORTD.2
PORTD.3
PORTD.4
PORTD.5
PORTD.6
PORTD.7

#define buzz PORTA.4
#define
#define
#define
#define
#define
#define
#define
#define

s8
s7
s6
s5
s4
s3
s2
s1

PINC.0
PINC.1
PINC.2
PINC.3
PINC.4
PINC.5
PINC.6
PINC.7

#define nyala 1
#define mati 0
int a;
// Alphanumeric LCD functions
#include <alcd.h>
// Declare your global variables here
void cepat()
{
unsigned char a,b;

. lcd_gotoxy(0. delay_ms(1000). delay_ms(1000). lcd_putsf("CEK LED6 NYALA"). led4=nyala.0). led3=nyala. lcd_gotoxy(0. lcd_gotoxy(0. lcd_putsf("CEK LED7 NYALA").0). } void cekled() { lcd_gotoxy(0. lcd_putsf("CEK LED5 NYALA"). lcd_putsf("CEK LED4 NYALA"). lcd_gotoxy(1.lcd_gotoxy(0. led7=nyala. lcd_gotoxy(0. delay_ms(1000). lcd_clear(). lcd_gotoxy(0. lcd_putsf("CEK LED8 NYALA"). led1=nyala.0).0).0). led1=nyala. delay_ms(1000). lcd_gotoxy(0. lcd_putsf("CEK LED2 NYALA"). lcd_putsf("CEK LED1 NYALA"). lcd_putsf("CEK LED3 NYALA"). led5=nyala. lcd_putsf("C"). delay_ms(1000).0). delay_ms(1000).0). delay_ms(1000). lcd_putsf("f"). led2=nyala. lcd_gotoxy(0. lcd_putsf("e").0). lcd_putsf("d").0).1). lcd_gotoxy(0. delay_ms(1000). led6=nyala. led8=nyala.0). lcd_gotoxy(2.0).

delay_ms(1000). lcd_gotoxy(0. led5=mati.0). led1=led2=led3=led4=led5=led6=led7=led8=mati. lcd_gotoxy(0. lcd_putsf("CEK LED5 MATI").0).0). } . delay_ms(1000).1).0). delay_ms(1000).0). lcd_gotoxy(0. lcd_clear(). led8=mati. lcd_gotoxy(0. lcd_putsf("CEK LED7 MATI"). led1=mati. delay_ms(100). delay_ms(1000). lcd_putsf("CEK LED1 MATI"). led7=mati. lcd_putsf("CEK LED6 MATI"). lcd_gotoxy(0. lcd_putsf("SAKLAR 1").0).0).0). delay_ms(1000). if(s1==0) { led1=nyala. led3=mati.0). lcd_putsf("TEKAN RESET-MENU"). lcd_gotoxy(0.lcd_gotoxy(0. lcd_gotoxy(0. delay_ms(1000). lcd_putsf("CEK LED3 MATI"). delay_ms(1000). led2=mati. } void ceksaklar() { saklar: lcd_clear(). lcd_putsf("CEK LED8 MATI"). delay_ms(100). delay_ms(1000). lcd_putsf("SELESAI"). lcd_putsf("CEK LED4 MATI"). delay_ms(1000). lcd_gotoxy(0. lcd_gotoxy(0. lcd_putsf("CEK LED2 MATI"). led6=mati. led4=mati. lcd_gotoxy(0.0).

if(s2==0) { led2=nyala. lcd_gotoxy(0. delay_ms(100). lcd_putsf("SAKLAR 6"). lcd_putsf("SAKLAR 8").0). lcd_putsf("SAKLAR 5"). } if(s6==0) { led6=nyala. delay_ms(100). lcd_putsf("SAKLAR 2"). } if(s5==0) { led5=nyala.0). } goto saklar. } if(s8==0) { led8=nyala. delay_ms(100). delay_ms(100).0).0). lcd_putsf("SAKLAR 7"). lcd_gotoxy(0. lcd_gotoxy(0. delay_ms(100).0). lcd_gotoxy(0. lcd_putsf("SAKLAR 3"). lcd_gotoxy(0. } if(s7==0) { led7=nyala. lcd_putsf("SAKLAR 4"). } if(s4==0) { led4=nyala. delay_ms(100).0). delay_ms(100).0). lcd_gotoxy(0. lcd_gotoxy(0. } if(s3==0) { led3=nyala. } void keypad() { .

lcd_gotoxy (0. lcd_putsf ("C"). delay_ms(100). delay_ms(100). PORTC = 0b11111101. lcd_putsf(" "). lcd_putsf ("#"). lcd_putsf(" "). PORTC = 0b11111110. delay_ms(100). lcd_putsf ("6"). delay_ms(100).1). } else if (PINC==0b10111110){ lcd_gotoxy (0. lcd_putsf(" "). lcd_gotoxy (0. delay_us(1).delay_ms(1000).0). if (PINC==0b11101101){ lcd_gotoxy (0. lcd_putsf ("D").0). }. DDRC = 0b00001111. lcd_gotoxy (0. . lcd_putsf(" ").0). delay_ms(100). } else if (PINC==0b01111110){ lcd_gotoxy (0. lcd_gotoxy (0. lcd_putsf ("9").0).0). } else if (PINC==0b10111101){ lcd_gotoxy (0. lcd_putsf(" "). //delay_ms(100).0).0). lcd_putsf ("B").0). } else if (PINC==0b11011110){ lcd_gotoxy (0.0).0). lcd_gotoxy (0. lcd_putsf ("TEKAN RESET-MENU"). keypadlagi: lcd_gotoxy (0. lcd_gotoxy (0. lcd_gotoxy (0. lcd_putsf ("A").0). lcd_putsf(" ").0). } else if (PINC==0b11011101){ lcd_gotoxy (0. delay_ms(100).0). delay_ms(100). delay_us(1).0). if (PINC==0b11101110){ lcd_gotoxy (0. DDRC = 0b00001111.

lcd_gotoxy (0.0).0). PORTC = 0b11110111. delay_us(1). lcd_putsf(" "). if (PINC==0b11101011){ lcd_gotoxy (0. DDRC = 0b00001111. lcd_gotoxy (0. if (PINC==0b11100111) { lcd_gotoxy (0. lcd_putsf ("7"). delay_ms(100). lcd_putsf(" "). } else if (PINC==0b01111101){ lcd_gotoxy (0. lcd_putsf(" ").0). } else if (PINC==0b01111011){ lcd_gotoxy (0. lcd_putsf(" "). lcd_putsf ("2"). //delay_ms(100). PORTC = 0b11111011.0). lcd_putsf(" "). lcd_gotoxy (0. delay_ms(100). //delay_ms(100).0). }.0). } else if (PINC==0b10111011){ lcd_gotoxy (0.0).0). } else if (PINC==0b10110111){ . delay_us(1). delay_ms(100). lcd_gotoxy (0.0). lcd_putsf ("8"). lcd_putsf ("5"). lcd_putsf ("*").lcd_putsf(" "). delay_ms(100). lcd_gotoxy (0. DDRC = 0b00001111. delay_ms(100).0). lcd_putsf(" "). lcd_gotoxy (0.0). lcd_gotoxy (0. lcd_putsf ("0"). delay_ms(100).0). lcd_putsf ("3"). lcd_putsf(" "). delay_ms(100). }. } else if (PINC==0b11011011){ lcd_gotoxy (0.0). } else if (PINC==0b11010111){ lcd_gotoxy (0.0).

delay_ms(500). lcd_clear(). lcd_gotoxy(0.. delay_ms(100).0). }. lcd_gotoxy(0. lcd_gotoxy(a. lcd_putsf("Loading...0). delay_ms(100).").0).. buzz=nyala. } else if (PINC==0b01110111){ lcd_gotoxy (0.").. lcd_putsf("Loading. lcd_putsf ("4"). lcd_gotoxy (0. buzz=nyala. lcd_putsf("Loading.."). delay_ms(100). buzz=mati."). lcd_putsf("#"). goto keypadlagi.0).. //delay_ms(100). lcd_putsf("Loading..0).0). delay_ms(100). lcd_gotoxy (0.a++) { lcd_gotoxy(a. delay_ms(100)... lcd_putsf(" ")..").0). lcd_putsf("#"). } void ceklcd() { for(a=0. delay_ms(100).. lcd_putsf("Loading. lcd_gotoxy(0. buzz=mati.a<16..0).. delay_ms(100)....0).0).0). buzz=nyala.. lcd_putsf(" "). lcd_putsf("Loading..1). delay_ms(100). lcd_gotoxy(0. lcd_putsf ("1"). lcd_gotoxy(0.").. .. buzz=mati.").0). buzz=nyala. lcd_gotoxy(0. } } void loading() { lcd_gotoxy(0. delay_ms(100). lcd_putsf("Loading.lcd_gotoxy (0.

lcd_putsf("Loading.. lcd_clear(). . // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer1 Stopped // Mode: Normal top=0xFFFF // OC1A output: Discon.. lcd_gotoxy(0.. buzz=mati.0)."). // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00. // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=0xFF // OC0 output: Disconnected TCCR0=0x00.. DDRC=0x00."). TCNT0=0x00.0).. OCR0=0x00. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=0x00. DDRD=0xFF... delay_ms(100).. DDRA=0xFF.. // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00. // OC1B output: Discon... lcd_putsf("Loading.. // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0xFF..lcd_gotoxy(0.. delay_ms(100). } void main(void) { // Declare your local variables here // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00. DDRB=0x00..

// USART initialization // USART disabled UCSRB=0x00. // // // // // // // // Alphanumeric LCD initialization Connections are specified in the Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: RS .PORTB Bit 2 D4 . // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off MCUCR=0x00. ICR1L=0x00.PORTB Bit 1 EN . OCR1AH=0x00. // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00. // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped // Mode: Normal top=0xFF // OC2 output: Disconnected ASSR=0x00. // SPI initialization // SPI disabled SPCR=0x00.TCCR1B=0x00. TCNT1L=0x00.PORTB Bit 5 . ICR1H=0x00. // ADC initialization // ADC disabled ADCSRA=0x00. MCUCSR=0x00. // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80. OCR1BH=0x00. TCNT1H=0x00. OCR2=0x00. // TWI initialization // TWI disabled TWCR=0x00. TCCR2=0x00.PORTB Bit 0 RD .PORTB Bit 4 D5 . OCR1BL=0x00. OCR1AL=0x00. TCNT2=0x00. SFIOR=0x00.

while (1) { // Place your code here cepat().PORTB Bit 7 // Characters/line: 16 lcd_init(16). } } .// D6 .PORTB Bit 6 // D7 .