|
include "main.h"
#include "uart.h"
unsigned char KEY_NUM = 0;
//**********************************************************
//主函數(shù)
//**********************************************************
void main()
{
Uart_Init(); //初始化串口,設(shè)置為9600波特率
Delay_ms(100);
while(1)
{
Scan_Key();
if(KEY_NUM == 1)
{
UartPrintf("AT+COLP=1\r\n"); //AT+COLP=1,開啟被叫號碼顯示,當(dāng)成功撥通的時候(被叫接聽電話),模塊會返回被叫號碼。
Delay_ms(1000);
UartPrintf("ATD18067933376\r\n"); //可從此條語句修改需要更換的手機(jī)號,將18067933376修改為您需要撥打的手機(jī)號
Delay_ms(1000);
}
else if(KEY_NUM == 2)
{
UartPrintf("ATH\r\n"); //掛機(jī)指令
Delay_ms(1000);
}
}
}
//**********************************************************
//延時函數(shù),延時1s
//**********************************************************
void Delay_ms( unsigned int m)
{
unsigned int j;
unsigned int i;
for(i = 0 ; i < m ; i++)
{
for(j = 0 ; j < 123 ; j++);
}
}
//掃描按鍵
void Scan_Key()
{
KEY_NUM = 0;
if(KEY1 == 0)
{
Delay_ms(20);
if(KEY1 == 0)
{
KEY_NUM = 1;
while(KEY1 == 0);
}
}
if(KEY2 == 0)
{
Delay_ms(20);
if(KEY2 == 0)
{
KEY_NUM = 2;
while(KEY2 == 0);
}
}
if(KEY3 == 0)
{
Delay_ms(20);
if(KEY3 == 0)
{
KEY_NUM = 3;
while(KEY3 == 0);
}
}
if(KEY4 == 0)
{
Delay_ms(20);
if(KEY4 == 0)
{
KEY_NUM = 4;
while(KEY4 == 0);
}
}
}
|
-
-
1.例程.7z
2020-8-4 14:17 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
4.74 MB, 下載次數(shù): 6, 下載積分: 黑幣 -5
|