小项目实践:单片机做的半导*冷小冰箱 原理图和程序
最近天气比较炎热闲来无事,自己在家DIY了一个小冰箱,试了一下制冷效果还可以的,下面就把制作步骤和技术资料和大家共享一下:
这个冰冰可乐什么的真的太适合不过了。。器材:一个电源模块,220v转12v,6A。以及一个封装好的制冷器,元件清单都在原理图上可以看出来,继电器用的是继电器模块。
防水型的18B20,继电器模块,12c887时间芯片,12864液晶屏,蜂鸣器,89c58单片机芯片,接线子,什么开关,按键,电阻电容的你也应该知道的,就是一个单片机模块。。这些就是控制板的元件了,然后你还要去淘宝上买制冷器和制冷器血药的配套的电源模块。。然后你就可以自己DAY一个小冰箱了。。
废话不多说先上图:
这是系统控制板子需要自己DIY的板子散件,待焊接
焊接好的系统控制板成品
连接好的待测试品
接上显示LCD后可以显示的功能
系统完整演示图
智能小冰箱的C语言参考源代码:
#include
#include
#define uchar unsigned char
#define uint unsigned int
sbit ds=P2^2;
sbit rs=P3^5;
sbit rw=P3^6;
sbit en=P3^4;
sbit psb=P3^7;
sbit feng=P2^0;
sbit dscs=P1^4;
sbit dsas=P1^5;
sbit dsrw=P1^6;
sbit dsds=P1^7;
sbit dsirq=P3^3;
sbit jidianqi=P2^3;
bit flag1,flag_ri;
sbit xuanzhe=P1^0;
sbit queding=P1^1;
sbit fanhui=P1^2;
sbit tiaozheng=P1^3;
sbit zengjia=P3^0;
sbit jianxiao=P3^1;
uint temp;
int x1,x3;
uchar flog1,flog,count,count1,acount1,count2,acount2,s1num,flag,t0_num,ff,xh,xh1,xh2,xw,xw1,xw2,xx,xt,axt,xt1,axt1,hh,ahh;
char miao,shi,fen,year,month,day,week,amiao,afen,ashi;
float f_temp;
uchar code table00[]={" 系统初始化… “};
uchar code table01[]={” 以关闭"};
uchar code table02[]={" 以开启"};
uchar code table0_0[]={“电气与”};
uchar code table0_1[]={" 信息工程学院"};
uchar code table0_2[]={"–电气1302唐小旺"};
uchar code table0_3[]={" 湖南工学院 "};
uchar code table11[]={“2015年00月00日”};
uchar code table12[]={" “};
uchar code table13[]={” 00: 00: 00"};
uchar code table14[]={“当前温度:”};
uchar code table1[]={“菜 1:温度调节”};
uchar code table2[]={“单 2:定时关闭”};
uchar code table3[]={“1 3:报警温度调”};
uchar code table4[]={" 4:时间调节"};
uchar code table5[]={“菜 5:闹钟调节”};
uchar code table6[]={“单 6:小小游戏”};
uchar code table7[]={“2 7:小小说明”};
uchar code table8[]={"–在按选择键返回"};
uchar code table1_1[]={“设置温度:”};
uchar code table1_2[]={" 00"};
uchar code table1_3[]={""};
uchar code table1_4[]={""};
uchar code table1_5[]={" 设置成功"};
uchar code table1_6[]={""};
uchar code table1_7[]={""};
uchar code table1_8[]={""};
uchar code table2_1[]={“设置定时开关:”};
uchar code table2_2[]={" 1:开启定时关闭"};
uchar code table2_3[]={" 2:关闭定时关闭"};
uchar code table2_4[]={"~~~~~~~~~~~~~~~~"};
uchar code table2_5[]={“设置时间:”};
uchar code table2_6[]={" 00: 00: 00"};
uchar code table2_7[]={""};
uchar code table2_8[]={" 设置成功"};
uchar code table2_9[]={“正在计时关闭中”};
uchar code table2_a[]={""};
uchar code table2_b[]={""};
uchar code table2_c[]={" 设置成功"};
uchar code table2_d[]={“以关闭定时关闭”};
uchar code table2_e[]={""};
uchar code table3_1[]={“设置报警温度:”};
uchar code table3_2[]={" 00"};
uchar code table3_3[]={""};
uchar code table3_4[]={""};
uchar code table3_5[]={" 设置成功"};
uchar code table3_6[]={" 滴滴滴滴"};
uchar code table3_7[]={“定时炸弹即将爆炸”};
uchar code table4_1[]={“设置时间:”};
uchar code table4_2[]={“2015年03月22日”};
uchar code table4_3[]={" Sun “};
uchar code table4_4[]={” 00: 00: 00 “};
uchar code table4_5[]={” 设置成功"};
uchar code table4_6[]={“春天到了!”};
uchar code table4_7[]={“I am coming”};
uchar code table4_8[]={" 师院"};
uchar code table5_1[]={“设置闹钟:”};
uchar code table5_2[]={" 1:开启闹钟"};
uchar code table5_3[]={" 2:关闭闹钟"};
uchar code table5_4[]={" 00: 00: 00 “};
uchar code table5_7[]={” 设置成功"};
uchar code table5_8[]={" 小鸡小鸡"};
uchar code table5_9[]={“小鸡小鸡咕咕day”};
uchar code table5_a[]={"(咦,我的闹铃)~~"};
uchar code table5_5[]={“设置时间:”};
uchar code table5_6[]={" 00: 00: 00"};
uchar code table5_b[]={""};
uchar code table5_c[]={" 设置成功"};
uchar code table5_d[]={“闹钟以关闭”};
uchar code table5_e[]={""};
uchar code table6_1[]={" 咦!!!"};
uchar code table6_2[]={" 游戏捏?"};
uchar code table7_1[]={“小慧是傻逼”};
uchar code table7_2[]={" 小慧是傻逼"};
uchar code table7_3[]={" 小慧是傻逼"};
uchar code table7_4[]={" 小慧是傻逼"};
uchar code table7_5[]={“当前温度:”};
uchar code table7_6[]={" --’f i e r c e’"};
uchar code table7_7[]={" no way!!"};
uchar code table7_8[]={" 谢谢合作"};
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x–)
for(y=110;y>0;y–);
}
void di()
{
feng=0;
delay(100);
feng=1;
}
void write_com(uchar com)
{
rs=0;
rw=0;
en=0;
P0=com;
delay(5);
en=1;
delay(5);
en=0;
}
void write_dat(uchar dat)
{
rs=1;
rw=0;
en=0;
P0=dat;
delay(5);
en=1;
delay(5);
en=0;
}
void dsreset(void)
{
uint i;
ds=0;
i=103;
while(i>0)i–;
ds=1;
i=4;
while(i>0)i–;
}
bit tempreadbit(void)
{
uint i;
bit dat;
ds=0;i++;
ds=1;i++;i++;
dat=ds;
i=8;while(i>0)i–;
return(dat);
}
uchar tempread(void)
{
uchar i,j,dat;
dat=0;
for(i=1;i<=8;i++)
{
j=tempreadbit();
dat=(j<<7)|(dat>>1);
}
return(dat);
}
void tempwritebyte(uchar dat)
{
uint i;
uchar j;
bit testb;
for(j=0;j<8;j++)
{
testb=dat&0x01;
dat=dat>>1;
if(testb)
{
ds=0;
i++;i++;
ds=1;
i=8;
while(i>0)i–;
}
else
{
ds=0;
i=8;
while(i>0)i–;
ds=1;
i++;
i++;
}
}
}
void tempchang(void)
{
dsreset();
delay(1);
tempwritebyte(0xcc);
tempwritebyte(0x44);
}
uint get_temp()
{
uchar a,b;
dsreset();
delay(1);
tempwritebyte(0xcc);
tempwritebyte(0xbe);
a=tempread();
b=tempread();
temp=b;
temp<<=8;
temp=temp|a;
f_temp=temp0.0625;
temp=f_temp10+0.5;
f_temp=f_temp+0.05;
return temp;
}
void write_ds(uchar add,uchar dat)
{
dscs=0;
dsas=1;
dsds=1;
dsrw=1;
P0=add;
dsas=0;
dsrw=0;
P0=dat;
dsrw=1;
dsas=1;
dscs=1;
}
uchar read_ds(uchar add)
{
uchar ds_date;
dsas=1;
dsds=1;
dsrw=1;
dscs=0;
P0=add;
dsas=0;
dsds=0;
P0=0xff;
ds_date=P0;
dsds=1;
dsas=1;
dscs=1;
return ds_date;
}
/*void set_time()
{
write_ds(0,0);
write_ds(1,0);
write_ds(2,0);
write_ds(3,0);
write_ds(4,0);
write_ds(5,0);
write_ds(6,0);
write_ds(7,0);
write_ds(8,0);
write_ds(9,0);
} */
void init1()
{
EA=1;
EX1=1;
IT1=1;
t0_num=0;
s1num=0;
week=1;
// write_ds(0x0A,0x20);
// write_ds(0x0B,0x26);
// set_time();
}
void sfm_(uchar add,char dat)
{
uchar si,ge;
si=dat/10;
ge=dat%10;
write_com(add);
write_dat(0x30+si);
write_dat(0x30+ge);
}
void asfm_(uchar add,char dat)
{
uchar si,ge;
si=dat/10;
ge=dat%10;
write_com(add);
write_dat(0x30+si);
write_dat(0x30+ge);
}
void week_(uchar add,char week)
{
write_com(add);
if(week0)
{
write_dat(0x4D);
write_dat(0x6F);
write_dat(0x6E);
write_dat(0x20);
}
if(week1)
{
write_dat(0x54);
write_dat(0x75);
write_dat(0x65);
write_dat(0x73);
}
if(week2)
{
write_dat(0x57);
write_dat(0x65);
write_dat(0x64);
write_dat(0x20);
}
if(week3)
{
write_dat(0x54);
write_dat(0x68);
write_dat(0x75);
write_dat(0x72);
}
if(week4)
{
write_dat(0x46);
write_dat(0x72);
write_dat(0x69);
write_dat(0x20);
}
if(week5)
{
write_dat(0x53);
write_dat(0x61);
write_dat(0x74);
鉴于篇幅限制,只能写部分代码
最后,如果需要 程序完整源代码和 技术文件,请在下方留言或者私信我,看到后会第一时间回复。
谢谢!