前几天一个朋友对我说,马上要过年了
准备买点年货放冰箱,正好我最近不太忙,便想着做一个小冰箱玩玩
废话不多说,先介绍器材
器材:一个电源模块,220v转12v,6A。以及一个封装好的制冷器,元件清单都在原理图上可以看出来,继电器用的是继电器模块。
防水型的18B20,继电器模块,12c887时间芯片,12864液晶屏,蜂鸣器,89c58单片机芯片,接线子,什么开关,按键,电阻电容的你也应该知道的,就是一个单片机模块。。这些就是控制板的元件了,然后你还要去淘宝上买制冷器和制冷器血药的配套的电源模块。。然后你就可以自己DAY一个小冰箱了。。
先上实物图,整个过程需要自己亲力亲为,虽然有点麻烦,但是里面还是有很大乐趣的
这是控制系统板子散件
焊接好的控制板
连接好的整个系统
下图这些显示都是可以实现的功能。。
这是一个定时关闭的功能
时间设置及其他功能
最低温度你们看吧!这个小冰箱实际测试结果我还是挺满意的,可以喝冰镇啤酒饮料,这几实验基本成功。
搭的系统有点丑,我下次有时间再改进一下,因为都是模块搭的,所以就不过多啰嗦了,
89c58单片机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);
}
if(week==6)
{
write_dat(0x53);
write_dat(0x75);
write_dat(0x6E);
write_dat(0x20);
}
}
void nyr_(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 tx(uchar add,uint dat)
{
uchar shi,ge,xs;
shi=(dat)/100;
ge=(dat)%100/10;
xs=(dat)%100%10;
write_com(0x98+add);
write_dat(0x30+shi);
write_dat(0x30+ge);
write_dat(0x2e);
write_dat(0x30+xs);
write_com(0x9f);
write_dat(0xA1);
write_dat(0xE6);
}
void x1_(int x1)
{
uchar si,ge;
si=x1/10;
ge=x1%10;
write_com(0x93);
write_dat(0x30+si);
write_dat(0x30+ge);
}
void x3_(int x3)
{
uchar si,ge;
si=x3/10;
ge=x3%10;
write_com(0x93);
write_dat(0x30+si);
write_dat(0x30+ge);
}
void lcd_init()
{
uchar i;
psb=1;
write_com(0x30);
delay(5);
write_com(0x0c);
delay(5);
write_com(0x01);
delay(5);
write_com(0x90);
i=0;
while(table00[i]!=’’)
{
write_dat(table00[i]);
i++;
}
delay(700);
write_com(0x01);
delay(500);
write_com(0x90);
i=0;
while(table00[i]!=’’)
{
write_dat(table00[i]);
i++;
}
delay(700);
write_com(0x01);
delay(500);
write_com(0x90);
i=0;
while(table00[i]!=’’)
{
write_dat(table00[i]);
i++;
}
delay(700);
write_com(0x01);
delay(500);
write_com(0x90);
i=0;
while(table0_3[i]!=’’)
{
write_dat(table0_3[i]);
i++;
delay(100);
}
delay(700);
write_com(0x01);
write_com(0x90);
i=0;
while(table0_0[i]!=’’)
{
write_dat(table0_0[i]);
i++;
delay(50);
}
write_com(0x88);
i=0;
while(table0_1[i]!=’’)
{
write_dat(table0_1[i]);
i++;
delay(50);
}
write_com(0x98);
i=0;
while(table0_2[i]!=’’)
{
write_dat(table0_2[i]);
i++;
delay(50);
}
delay(700);
write_com(0x01);
write_com(0x80);
i=0;
while(table11[i]!=’’)
{
write_dat(table11[i]);
i++;
}
write_com(0x90);
i=0;
while(table12[i]!=’’)
{
write_dat(table12[i]);
i++;
}
write_com(0x88);
i=0;
while(table13[i]!=’’)
{
write_dat(table13[i]);
i++;
}
write_com(0x98);
i=0;
while(table14[i]!=’’)
{
write_dat(table14[i]);
i++;
}
ff=1;
}
void xuanzhe_()
{
uchar i;
if((xuanzhe0)&&(flog10))
{
delay(10);
if(xuanzhe0)
{
while(!xuanzhe);
count++;
ff=0;
di();
if(count1)
{
flog=1;
write_com(0x01);
write_com(0x80);
i=0;
while(table1[i]!=’’)
{
write_dat(table1[i]);
i++;
}
write_com(0x81);
write_dat(0x02);
write_com(0x90);
i=0;
while(table2[i]!=’’)
{
write_dat(table2[i]);
i++;
}
write_com(0x88);
i=0;
while(table3[i]!=’’)
{
write_dat(table3[i]);
i++;
}
write_com(0x98);
i=0;
while(table4[i]!=’’)
{
write_dat(table4[i]);
i++;
}
}
if(count2)
{
flog=2;
write_com(0x01);
write_com(0x80);
i=0;
while(table1[i]!=’’)
{
write_dat(table1[i]);
i++;
}
write_com(0x90);
i=0;
while(table2[i]!=’’)
{
write_dat(table2[i]);
i++;
}
write_com(0x91);
write_dat(0x02);
write_com(0x88);
i=0;
while(table3[i]!=’’)
{
write_dat(table3[i]);
i++;
}
write_com(0x98);
i=0;
while(table4[i]!=’’)
{
write_dat(table4[i]);
i++;
}
}
if(count3)
{
flog=3;
write_com(0x01);
write_com(0x80);
i=0;
while(table1[i]!=’’)
{
write_dat(table1[i]);
i++;
}
write_com(0x90);
i=0;
while(table2[i]!=’’)
{
write_dat(table2[i]);
i++;
}
write_com(0x88);
i=0;
while(table3[i]!=’’)
{
write_dat(table3[i]);
i++;
}
write_com(0x89);
write_dat(0x02);
write_com(0x98);
i=0;
while(table4[i]!=’’)
{
write_dat(table4[i]);
i++;
}
}
if(count==4)
{
flog=4;
write_com(0x01);
write_com(0x80);
i=0;
while(table1[i]!=’’)
{
write_dat(table1[i]);
i++;
}
write_com(0x90);
i=0;
while(table2[i]!=’’)
{
write_dat(table2[i]);
i++;
}
write_com(0x88);
i=0;
while(table3[i]!=’’)
{
write_dat(table3[i]);
i++;
}
write_com(0x98);
i=0;
while(table4[i]!=’’)
{
write_dat(table4[i]);
i++;
}
write_com(0x99);
write_dat(0x02);
}
if(count5)
{
flog=5;
write_com(0x01);
write_com(0x80);
i=0;
while(table5[i]!=’’)
{
write_dat(table5[i]);
i++;
}
write_com(0x81);
write_dat(0x02);
write_com(0x90);
i=0;
while(table6[i]!=’’)
{
write_dat(table6[i]);
i++;
}
write_com(0x88);
i=0;
while(table7[i]!=’’)
{
write_dat(table7[i]);
i++;
}
write_com(0x98);
i=0;
while(table8[i]!=’’)
{
write_dat(table8[i]);
i++;
}
}
if(count6)
{
flog=6;
write_com(0x01);
write_com(0x80);
i=0;
while(table5[i]!=’’)
{
write_dat(table5[i]);
i++;
}
write_com(0x90);
i=0;
while(table6[i]!=’’)
{
write_dat(table6[i]);
i++;
}
write_com(0x91);
write_dat(0x02);
write_com(0x88);
i=0;
while(table7[i]!=’’)
{
write_dat(table7[i]);
i++;
}
write_com(0x98);
i=0;
while(table8[i]!=’’)
{
write_dat(table8[i]);
i++;
}
}
if(count7)
{
flog=7;
write_com(0x01);
write_com(0x80);
i=0;
while(table5[i]!=’’)
{
write_dat(table5[i]);
i++;
}
write_com(0x90);
i=0;
while(table6[i]!=’’)
{
write_dat(table6[i]);
i++;
}
write_com(0x88);
i=0;
while(table7[i]!=’’)
{
write_dat(table7[i]);
i++;
}
write_com(0x89);
write_dat(0x02);
write_com(0x98);
i=0;
while(table8[i]!=’’)
{
write_dat(table8[i]);
i++;
}
}
if(count8)
{
count=1;
flog=1;
write_com(0x01);
write_com(0x80);
i=0;
while(table1[i]!=’’)
{
write_dat(table1[i]);
i++;
}
write_com(0x81);
write_dat(0x02);
write_com(0x90);
i=0;
while(table2[i]!=’’)
{
write_dat(table2[i]);
i++;
}
。。。。。。。。。。。。。。。。。。。
源代码很长,鉴于篇幅限制,只能写部分代码
最后,如果有什么意见或者建议欢迎您留言给我,让我们共同学习一起进步,
如果需要 程序完整源代码和 设计文件,请在下方留言或者私信我,看到后会第一时间回复。
谢谢!