基于单片机的洗衣机控制系统设计

附录

_nop_(); Clk=0; DATI=0; _nop_(); Clk=1; _nop_(); } else { Clk = 0; DATI = 1; _nop_(); Clk = 1; _nop_(); Clk = 0; DATI = 1; _nop_(); Clk = 1; _nop_(); }

Clk = 0; DATI = 1;

for( i = 0;i < 8;i++ ) { _nop_(); adval <<= 1; Clk = 1; _nop_(); Clk = 0; if (DATO) adval |= 0x01; else adval |= 0x00; }

for (i = 0; i < 8; i++) { test >>= 1; if (DATO) test |= 0x80; else test |= 0x00;

39

附录

_nop_(); Clk = 1; _nop_(); Clk = 0; }

if (adval == test) dat = test; nop_();

CS = 1; DATO = 1; Clk = 1; return dat; }

/**显示子程**/ void display() {

DUAN=~tab[min/10]; LED1=0; delay(2); LED1=1;

DUAN=~tab[min]; DIAN=0; LED2=0; delay(2); LED2=1;

DUAN=~tab[sec/10]; LED3=0; delay(2); LED3=1;

DUAN=~tab[sec]; LED4=0; delay(2); LED4=1; }

void read_0832() {

uint sum;

40

附录

uchar read_num;

for(read_num=0;read_num<20;read_num++) { dat=adc0832(CH); sum=sum+dat; display(); }

dat=sum/20; sum=0; }

/**按键子程**/ void KEY() {

// uchar time_start;

if(KEY_MODE==0&&TR0==0) { delay(20); if(KEY_MODE==0) { buzz=0; delay(20); buzz=1; MODE++; if(MODE==1) {min=20;sec=0;LED_15min=1;LED_20min=0;} else if(MODE==2) {min=30;sec=0;LED_20min=1;LED_30min=0;} else if(MODE==3) {min=3;sec=0;LED_30min=1;} if(MODE>=4) { MODE=0; min=15; sec=0; LED_15min=0; } while(KEY_MODE==0) display(); } }

if(KEY_PAUSE==0) { delay(20);

41

附录

if(KEY_PAUSE==0) { buzz=0; delay(20); buzz=1; flag_START=~flag_START; if(NUM==1||NUM==4||NUM==6) { TR0=!TR0; MOTOR_R=1; MOTOR_L=1; } // NUM=0; //TR1=flag_START; while(KEY_PAUSE==0) display(); } } }

//**工作子程**// void work() {

read_0832(); if(flag_START==1)

{ if(min<=3&&dat<100) { TR0=1; LED_WASH=1; LED_RINSE=1; WATER_IN=1; WATER_OUT=1; LED_DRY=0; MOTOR_WASH_DRY=1; MOTOR_R=0; MOTOR_L=1; } else if(min<=3&&dat>100) { TR0=0; LED_WASH=1; LED_RINSE=1;

42

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4