自動洗鞋機控制
大電機轉(zhuǎn)動(正反轉(zhuǎn))帶動中心柱轉(zhuǎn),從而帶動鞋子轉(zhuǎn)動,同時小電機轉(zhuǎn)動帶動中心柱上齒輪轉(zhuǎn)動,帶動支撐件上下移動,洗刷結(jié)束后,控制電磁閥打開排水,排完之后中心柱再轉(zhuǎn)起來,給鞋子脫水,脫水結(jié)束后控制風(fēng)扇的小電機轉(zhuǎn)動,PTC陶瓷發(fā)熱片接電發(fā)熱(一定時間),最后有個蜂鳴器報警。洗刷-排數(shù)-脫水-烘干
bit smg1=P2^0;//數(shù)碼管
sbit smg2=P2^1;
sbit smg3=P2^2;
sbit smg4=P2^3;
sbit out1=P2^4;//電機
sbit out2=P2^5;
sbit out3=P2^6;
sbit out4=P2^7;
sbit beep=P1^7;//蜂鳴器
sbit out5=P3^0;//輸出控制
sbit out6=P3^1;
sbit out7=P3^2;
sbit k1=P1^0;//按鈕
sbit k2=P1^1;
sbit k3=P1^2;
sbit led1=P3^4;//LED
sbit led2=P3^5;
sbit led3=P3^6;
sbit led4=P3^7;
sbit led5=P3^3;
//數(shù)碼管編碼
uchar code smgduan0[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//顯示0~9,無小數(shù)點
uchar code smgduan1[10]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};//顯示0~9,有小數(shù)點
uchar time=0,mode=0;//系統(tǒng)變量
uchar fen=0,miao=0;//計時
uchar fen_set=0,miao_set=50;//總時間
uchar motor1_time=0,flag=0;//大電機計時
uchar beep_time=0;
uint sec=0;
uchar bei=0;
//延時
void delay(uint i)
{
while(i--);
}
//主函數(shù)
void main()
{
uchar i=0,k=0;
sec=fen_set*60+miao_set;
sec=sec/10;//時間拆分成10份
miao=miao_set;
fen=fen_set;
TMOD|=0X01;//初始化定時器
TH0=0X3C;
TL0=0XB0;
ET0=1;//打開定時器0中斷允許
EA=1;//打開總中斷
TR0=1;//打開定時器
while(1)
{
//啟動
if(!k1)
{
if(mode==0)
mode=1;
if(mode==5)
mode=bei;
led5=1;
}
//停止
if(!k2)
{
mode=0;led5=1;
}
//暫停
if(!k3 &&(k!=3))
{
k=3;
if((mode>0)&&(mode<5))
{
bei=mode;
mode=5;
led5=0;
led1=1;
led2=1;
led3=1;
led4=1;
out1=1;
out2=1;
out3=1;
out4=1;
out5=1;
out6=1;
out7=1;
}
else if(mode==5)
{
mode=bei;
led5=1;
}
}
if(k3)
k=0;
//電機調(diào)速
if(i<10)
i++;
else
{
i=0;
}
if(mode==1)
{
if(flag==0)//洗刷
{
out2=1;
if(i<4)
out1=0;
else
out1=1;
}
else
{
out1=1;
if(i<4)
out2=0;
else
out2=1;
}
}
if(mode==3)//脫水
{
out1=0;
out2=1;
}
//顯示
P0=smgduan0[fen/10];
smg1=0;
delay(30);
smg1=1;
P0=smgduan1[fen%10];
smg2=0;
delay(30);
smg2=1;
P0=smgduan0[miao/10];
smg3=0;
delay(30);
smg3=1;
P0=smgduan0[miao%10];
smg4=0;
delay(30);
smg4=1;
}
}
//定時器中斷
void Timer0() interrupt 1
{
uint i;
if(time<20)//1s
資料借鑒于此?紛傳
閱讀全文