Sistem Pengamanan Sepeda Motor dengan Sidik Jari Berbasis Microkontroler Aatemega 8535 dan Menggunakan Modul GSM sebagai Pengontrol Jarak Jauh

LAMPIRAN
PROGRAM

Listing program dari seluruh sistem .
/**************************************************************************
***
CodeVisionAVR V2.0 C Compiler
(C) 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.

ATmega8535 I/O REGISTERS BIT DEFINITIONS
***************************************************************************
**/
#include
#include
#include
#include
#include
#include
#define ADC_VREF_TYPE 0x00

#define ubrr_val (fosc/(16*baud))-1

#define RXEN 4
#define TXEN 3
#define USBS 3
#define UCSZ0 1
#define USEL 7
#define RXC 7
unsigned int T1,T2;
char i,j,k,Data,c,status;
void SendMessage1(void);

Universitas Sumatera Utara

void ReadMessage(void);

void main(void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x01;
DDRB=0xFF;

PORTC=0x01;
DDRC=0x00;
PORTD=0xFF;
DDRD=0x00;

UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x4D;

i = 0;
k = 0;
j = 0;

delay_ms(1000);

Universitas Sumatera Utara

//printf("AT+CMGD=1,3");

//putchar(0x0D);
//while(getchar()!=0x0A){}
//while(getchar()!=0x0A){};

while (1)
{

if (i == 0) {PORTB.1 = 0;delay_ms(100);PORTB.1 = 1;delay_ms(900);}
if ((PIND.2 == 1)&&(i == 0)) {PORTB.0 = 0;PORTB.2 = 1;PORTB.3 = 0;i
= 1;delay_ms(5000);}
if ((PINC.0 == 0)&&(i == 0)) {PORTB.3 =
1;SendMessage1();ReadMessage();k=1;j=0;}
if ((PIND.2 == 1)&&(i == 1)) {PORTB.0 = 1;PORTB.2 = 0;PORTB.3 = 0;i
=
0;delay_ms(5000);printf("AT+CMGD=1,3");putchar(0x0D);while(getchar()!=0
x0A){} while(getchar()!=0x0A){}; }

j++;

}

}

void SendMessage1(void)

Universitas Sumatera Utara

{
printf("AT+CMGS=082273777732");

delay_ms(1000);
printf("%c",0x0D);
delay_ms(2000);
printf("Terdeteksi Gangguan pada sepeda motor anda, Alarm Aktif. Jika hendak
mematikan balas dgn kode Off !S");
delay_ms(1000);
printf("%c",0x1A);
delay_ms(5000);
printf("");

}


void ReadMessage(void)
{dc:
printf("AT+CMGR=1");
delay_ms(1000);
printf("%c",0x0D);

while(getchar()!=0x0A){}
while(getchar()!=0x0A){}
PORTB.1 = 0;

Universitas Sumatera Utara

for(c=0;c