// GY-26 IIC测试程序
// 使用单片机STC89C51
// 晶振:11.0592M
// 显示:LCD1602
// 编译环境 Keil uVision2
// 程序中把模块当24c04进行通信
#include 《REG51.H》
#include 《math.h》 //Keil library
#include 《stdio.h》 //Keil library
#include 《INTRINS.H》
#define uchar unsigned char
#define uint unsigned int
#define DataPort P0 //LCD1602数据端口
#define WriteDeviceAddress 0xE0 //定义器件在IIC总线中的地址
#define ReadDviceAddress 0xE1 //器件在IIC总线中地址+1
typedef unsigned char BYTE;
typedef unsigned short WORD;
BYTE BUF[8]; //数据缓存区
BYTE code res[6] _at_ 0x23;
sbit SCL=P1^0; //iic时钟引脚定义
sbit SDA=P1^1; //iic数据引脚定义
sbit LCM_RS=P2^0; //LCD1602命令端口
sbit LCM_RW=P2^1; //LCD1602命令端口
sbit LCM_EN=P2^2; //LCD1602命令端口
sbit KEY_1 =P2^6; //按键1
sbit KEY_2 =P2^5; //按键2
sbit KEY_3 =P2^4; //按键3
sbit KEY_4 =P2^3; //按键4


声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部1条评论
快来发表一下你的评论吧 !