【Proteus仿真】AT24C02数据读写+LCD1602显示
【Proteus仿真】AT24C02数据读写+LCD1602显示
- Proteus仿真

程序说明
- AT24C02采用的IIC通讯,SCK:P20;SDA:P21
- 按键K1-K4分别接到P30-P33引脚上。
主程序代码
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
| #include <REGX52.H> #include "LCD1602.h" #include "Key.h" #include "AT24C02.h" #include "Delay.h"
unsigned char KeyNum; unsigned int Num;
void main() { LCD\_Init(); LCD\_ShowNum(1,1,Num,5); while(1) { KeyNum=Key(); if(KeyNum==1) //K1按键,Num自增P3\_1 { Num++; LCD\_ShowNum(1,1,Num,5); } if(KeyNum==2) //K2按键,Num自减P3\_0 { Num--; LCD\_ShowNum(1,1,Num,5); } if(KeyNum==3) //K3按键,向AT24C02写入数据P3\_2 { AT24C02\_WriteByte(0,Num%256); Delay(5); AT24C02\_WriteByte(1,Num/256); Delay(5); LCD\_ShowString(2,1,"Write OK"); Delay(1000); LCD\_ShowString(2,1," "); } if(KeyNum==4) //K4按键,从AT24C02读取数据P3\_4 { Num=AT24C02\_ReadByte(0); Num|=AT24C02\_ReadByte(1)<<8; LCD\_ShowNum(1,1,Num,5); LCD\_ShowString(2,1,"Read OK "); Delay(1000); LCD\_ShowString(2,1," "); } } }
|
程序源码和仿真资源
本实验基于Proteus8.9SP2平台
1 2 3
| 链接:https://pan.baidu.com/s/1dt-wxFNmulZdwDDSQ2Y-Qw 提取码:i6rs
|
| 有缘和无缘那个其实也就是缘起缘灭,我们在缘起缘灭中我们度过了一生 |
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!