這是我最近剛做的oled仿真設(shè)計(jì),基于proteus8.11版本(其他版本打不開的),能夠顯示溫度、調(diào)節(jié)閾值。
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei圖片20210418161328.png (54.53 KB, 下載次數(shù): 107)
下載附件
2021-4-18 16:18 上傳
51hei.gif (95.19 KB, 下載次數(shù): 40)
下載附件
2023-4-13 03:53 上傳
部分單片機(jī)代碼如下:
#include "sys.h"
#include "usart.h"
#include "delay.h"
#include "led.h"
#include "key.h"
#include "oled.h"
#include "beep.h"
#include "rtc.h"
#include "ds18b20.h"
u8 year_buf[4];
u8 month_buf[2];
u8 day_buf[2];
u8 temp_buf[4];
u8 war[8];
u8 text[8];
u8 yuzhi=30;
int main(void)
{
short tem,tem1;
u8 B1_Flag=0;
u16 temp;
u8 key;
delay_init(); //延時(shí)初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置中斷優(yōu)先級分組為組2:2位搶占優(yōu)先級,2位響應(yīng)優(yōu)先級
Gpio_IIC_Init();
beep_Init();
Key_Init();
OLED_Init();
delay_ms(200);
OLED_CLS();
OLED_Refresh();
while(1)
{
tem = DS18B20_Get_Temp_Pin_11(); //獲取溫度
if( tem>0)
{
sprintf((char *)war,"Tem:%d%d.%d",tem/100,tem%100/10,tem%10);
}
else
{
tem1=(int)tem;
tem1=abs(tem1);
tem1=-(tem);
tem1=tem1+1;
sprintf((char *)war,"Tem:-%d%d.%d",tem1/100,tem1%100/10,tem1%10);
}
OLED_P8x16Str(8,2,war);
sprintf((char *)war,"yuzhi:%d",yuzhi);
OLED_P8x16Str(8,0,war);
if(tem>yuzhi*10)
{
PBeep=0;
}
if(tem<=yuzhi*10)
{
PBeep=1;
}
key=KEY_Scan();
if(key!=0)
{
switch(key)
{
case 1:
yuzhi++;
}
Keil代碼與Proteus8.13仿真下載:
程序.7z
(230.27 KB, 下載次數(shù): 631)
2021-4-18 17:08 上傳
點(diǎn)擊文件名下載附件
仿真.zip
(80.98 KB, 下載次數(shù): 673)
2021-4-18 16:21 上傳
點(diǎn)擊文件名下載附件
|