AVR ATmega8535
/*****************************************************
Chip type : ATmega8535
Program type : Application
Clock frequency : 11.059200 MHz
*****************************************************/
#include mega8535.h
#include
#include stdio.h
#define sensor0 PINA.0
#define sensor1 PINA.1
void main(void)
{
PORTA=0xff;
DDRA=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=0x19;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
//inisialisasi modem
printf ("AT\r");
printf ("ATE0\r"); // menonaktifkan echo
printf ("AT+CMGF="); // monest modem pada mode pesan teks
putchar ("1\r");
// tes kirim sms
printf("AT+CMGS="); // mengirim pesan teks tanpa menyimpan ke memory
putchar('"');
printf("03160542812"); // ini adalah no HP yg dikirim sms
putchar('"');
putchar(',');
putchar(13);
putchar(10);
printf("test Send SMS OK"); // isi pesan sms
putchar(26);
delay_ms(500);
while (1)
{
// Place your code here
if(sensor0==0)
{
printf("AT+CMGS=");
putchar('"');
printf("03160542812"); //--->ini adalah no HP yg dituju
putchar('"');
putchar(',');
putchar(13);
putchar(10);
printf("sensor0 AKTIF");
putchar(26);
}
if(sensor1==0)
{
printf("AT+CMGS=");
putchar('"');
printf("03160542812"); //--->ini adalah no HP yg dituju
putchar('"');
putchar(',');
putchar(13);
putchar(10);
printf("sensor1 AKTIF");
putchar(26);
}
delay_ms(500);
};
}
Sumber: www.avrku.com
0 Comments
Silahkan Tinggalkan Komentar Anda