|
單片機(jī)接受指定短信內(nèi)容,1602顯示短信內(nèi)容,單片機(jī)對短信內(nèi)容作判斷,若為所要求的內(nèi)容,則返回一條短信
51單片機(jī)控制sim900a收發(fā)短信源碼如下:
1602.c程序
- #include<reg52.h>
- #include "lcd1602_drv.h"
- sbit RS_1602=P2^6;
- sbit LCD_RW=P2^5; //LCD RW 主程序接地一直等于0
- sbit E_1602=P2^7;
- uchar aa,jj;
- //①寫命令子程序
- void write_1602com(uchar com) //液晶寫入指令函數(shù)
- {
- RS_1602=0; //置為寫入命令
- P0=com; //送入數(shù)據(jù)
- delay(1);
- E_1602=1;
- delay(1);
- E_1602=0;
- }
- //②寫數(shù)據(jù)子程序
- void write_1602dat(uchar dat)
- {
- RS_1602=1; //置為寫數(shù)據(jù)
- P0=dat; //送入數(shù)據(jù)
- delay(1);
- E_1602=1;
- delay(1);
- E_1602=0;
- }
- void lcd_init(void)
- {
- write_1602com(0x38); //16*2 5*7點(diǎn)陣 8位數(shù)據(jù)線
- delay(5);
- write_1602com(0x38);
- delay(5);
- write_1602com(0x38);
- delay(5);
- write_1602com(0x08);
- write_1602com(0x0c); //開顯示 不顯示光標(biāo) 不閃爍
- write_1602com(0x06); //顯示不移動 光標(biāo)右移
- write_1602com(0x01); // 清屏
- }
- lcd1602_drv.h部分
- #ifndef __LCD1602_DRV_H__
- #define __LCD1602_DRV_H__
- #define uchar unsigned char
- #define uint unsigned int
- #define one 0x80 //第一行的初始位置
- #define two 0x80+0x40
- void write_1602com(uchar com);
- void write_1602dat(uchar dat);
- void lcd_init();
- #endif
復(fù)制代碼
|
|