1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
| /*****************************************************
AVR Core Clock frequency: 11.059200 MHz
*****************************************************/
#include <mega16a.h>
#include <alcd.h>
#include <stdio.h>
#include <delay.h>
char at_cmgs[]={'A','T','+','C','M','G','S','=','"','0','9','1','1','8','5','3','0','9','6','1','"','\n'};
#define ctrl_z 0x1a
void main(void)
{
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0x02;
// 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;
// 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
lcd_init(16);
while (1)
{
delay_ms(2000);
puts("AT");
delay_ms(2000);
puts("AT");
delay_ms(2000);
puts("AT");
delay_ms(4000);
puts("ATE0");
delay_ms(4000);
puts("AT+CMGF=1");
delay_ms(4000);
puts(at_cmgs);
delay_ms(1000);
puts("this is test");
delay_ms(1000);
putchar(ctrl_z);
lcd_clear();
lcd_gotoxy(0,0);
lcd_puts("message sent");
}
} |