MTL_Monitor/tests/washing_machine/simple_controller/washing_machine.ino

102 lines
2.9 KiB
Arduino
Raw Permalink Normal View History

2023-05-04 11:46:50 +05:30
#define start 2;
#define fill 3;
#define soak 4;
#define spin_wash 5;
#define rinse 6;
#define drain 7;
#define spin_dry 8;
#define mode 9;
int status;
//start,fill,soak,dry
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
}
void loop() {
// put your main code here, to run repeatedly:
status = 2;
switch(status){
/*normal*/case 1: digitalWrite(2,HIGH); //start
delay(1000);
digitalWrite(2,LOW); //start
digitalWrite(3,HIGH); //fill
delay(4000);
digitalWrite(3,LOW);
digitalWrite(4,HIGH); //soak
delay(2000);
digitalWrite(4,LOW);
digitalWrite(5,HIGH); //wash
delay(5000);
digitalWrite(5,LOW);
digitalWrite(6,HIGH); //rinse
delay(3000);
digitalWrite(6,LOW);
digitalWrite(7,HIGH); //drain
delay(1000);
digitalWrite(7,LOW);
digitalWrite(8,HIGH); //dry
delay(4000);
digitalWrite(8,LOW);
break;
/*fast*/case 2: digitalWrite(2,HIGH); //start
delay(1000);
digitalWrite(3,HIGH); //fill
delay(2000);
digitalWrite(3,LOW); //fill
digitalWrite(2,LOW); //start -> stop
digitalWrite(4,HIGH); //soak
delay(4000);
digitalWrite(4,LOW); //soak
digitalWrite(5,HIGH); //wash
delay(4000);
digitalWrite(5,LOW); //wash
digitalWrite(6,HIGH); //rinse
delay(2000);
digitalWrite(6,LOW); //rinse
digitalWrite(7,HIGH); //drain
digitalWrite(8,HIGH); //dry
delay(4000);
digitalWrite(8,LOW); //dry
digitalWrite(7,LOW); //drain
break;
/*abnormal*/case 3:
digitalWrite(2,HIGH); //start
digitalWrite(3,HIGH); //fill
delay(4000);
digitalWrite(3,LOW);
digitalWrite(4,HIGH); //soak
delay(2000);
digitalWrite(4,LOW);
digitalWrite(5,HIGH); //wash
delay(5000);
digitalWrite(5,LOW);
digitalWrite(6,HIGH); //rinse
delay(3000);
digitalWrite(6,LOW);
digitalWrite(7,HIGH); //drain
delay(1000);
digitalWrite(7,LOW);
digitalWrite(8,HIGH); //dry
delay(4000);
digitalWrite(8,LOW);
break;
}
}