You are on page 1of 3

#include <mega8535.

h>
#include <alcd.h>
#include <delay.h>
#include <stdio.h>
#define delay delay_ms(200);
unsigned int i=0,S,P=0,A=0,Kec;
float Pulse,Putaran;
// Timer1 overflow interrupt service
routine
interrupt [TIM1_OVF] void
timer1_ovf_isr(void)
{
// Reinitialize Timer1 value
TCNT1H=0xD8EF >> 8;
TCNT1L=0xD8EF & 0xff;
S++;
if(S==1100)
{
i++;
S=0;

if(PINA.0==0 && PINA.1==1 &&


PINA.2==1 && PINA.3==0)
{putchar('2');}
if(PINA.0==0 && PINA.1==0 &&
PINA.2==1 && PINA.3==0)
{putchar('3');}
if(PINA.0==0 && PINA.1==0 &&
PINA.2==1 && PINA.3==1)
{putchar('4');}
if(PINA.0==0 && PINA.1==0 &&
PINA.2==0 && PINA.3==1)
{putchar('5');}
if(PINA.0==1 && PINA.1==0 &&
PINA.2==0 && PINA.3==1)
{putchar('6');}
if(PINA.0==1 && PINA.1==0 &&
PINA.2==0 && PINA.3==0)
{putchar('7');}

}
if(i<5)
{
if(PINA.4==0)
{A=0;}

if(PINA.0==1 && PINA.1==1 &&


PINA.2==0 && PINA.3==0)
{putchar('8');}
delay;
printf("$");
delay;
}

if(PINA.4==1 && A==0)


{P++;
A=1;
}
}

if(i==5)
{
printf("*");
delay;
Pulse=((float)P/36);
Putaran=((float)Pulse*62.8);
putchar(Kec);
delay;
printf("#");
delay;
P=0;
i=0;

// Declare your global variables here

if(PINA.0==0 && PINA.1==1 &&


PINA.2==0 && PINA.3==0)
{putchar('1');}

void main(void)
{
PORTA=0x00;
DDRA=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 11059,200 kHz
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: On
// Input Capture Interrupt: Off

// Compare A Match Interrupt: Off


// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x01;
TCNT1H=0xD8;
TCNT1L=0xEF;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0xFF;
OCR1AL=0xFF;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer(s)/Counter(s) Interrupt(s)
initialization
TIMSK=0x04;
// 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=0x47;
#asm("sei")
while (1)
{

}
}

#include
#include
#include
#include

<mega8535.h>
<alcd.h>
<stdio.h>
<delay.h>

unsigned char data;


char buff[33];
void main(void)
{
// 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=0x47;

if(data==0x32)
{lcd_gotoxy(6,0);
lcd_putsf("TIMUR LAUT");}
if(data==0x33)
{lcd_gotoxy(6,0);
lcd_putsf("TIMUR

if(data==0x34)
{lcd_gotoxy(6,0);
lcd_putsf("TENGGARA ");}

// Alphanumeric LCD initialization


// Connections are specified in the
// Project|Configure|C Compiler|
Libraries|Alphanumeric LCD menu:
// RS - PORTB Bit 0
// RD - PORTB Bit 1
// EN - PORTB Bit 2
// D4 - PORTB Bit 4
// D5 - PORTB Bit 5
// D6 - PORTB Bit 6
// D7 - PORTB Bit 7
// Characters/line: 16
lcd_init(16);

if(data==0x35)
{lcd_gotoxy(6,0);
lcd_putsf("SELATAN ");}
if(data==0x36)
{lcd_gotoxy(6,0);
lcd_putsf("BARAT DAYA");}
if(data==0x37)
{lcd_gotoxy(6,0);
lcd_putsf("BARAT

");}

if(data==0x38)
{lcd_gotoxy(6,0);
lcd_putsf("BARAT LAUT");}

while (1)
{
lcd_gotoxy(0,0);
lcd_putsf("ARAH:");
lcd_gotoxy(0,1);
lcd_putsf("KEC :");
lcd_gotoxy(12,1);
lcd_putsf("m/s");

}
}

while(data!=0x2A)
{data=getchar();}
data=getchar();
sprintf(buff,"%d",data);
lcd_gotoxy(7,1);
lcd_putsf("
");
lcd_gotoxy(6,1);
lcd_puts(buff);
while(data!=0x23)
{data=getchar();}
data=getchar();
if(data==0x31)
{lcd_gotoxy(6,0);
lcd_putsf("UTARA

");}

");}

You might also like