I have a project in embedded systems and I have to write the code in C, and make it simple.
This is my first time, and it's only a simulation of how it should work.
#include<iostream.h>
#include<stdio.h>
void manualMode();
void defaultMode();
int temp, timeToWash, operation;
int main() {
int mode =0, part=3, waterLevel;
int doorSensor=0, timer = 3,waterLevelSensor = 0, tempSensor = 25;
char startPause;
cout<<"Washing Machine CE224"<<endl;
do{
cout<<"Choose Mode: (1)Default, (2)Manual \n";
cin>>mode;
if (mode == 1)
defaultMode();
if (mode == 2)
manualMode();
}while(mode == 0);
cout<<"Choose Parts to wash: (1)Upper Only, (2)Lower Only, (3)Upper and Lower \n";
cin>>part;
switch(part){
case 1:
case 2:
waterLevel= 0.5;
break;
case 3:
waterLevel = 1;
break;
}
if (doorSensor == 0){
do{
cout<<"Press (S) to Start,and close the Door."<<endl;
cin>>startPause;
cout<<"LED is On\n";
while(waterLevelSensor != waterLevel){
waterLevelSensor++;
}
while(tempSensor != temp){
tempSensor++;
}
cout<<"Washing Operation Started! Time Left:"<<timeToWash<<endl;
cout<<"Washing with Soap Operation Started!\n";
timeToWash = timeToWash / 2 ;
cout<<"Rinsing Operation Started! Time Left:"<<timeToWash<<endl;
timeToWash = timeToWash / 2 ;
cout<<"Drying Operation Started! Time Left:"<<timeToWash<<endl;
timeToWash = 0 ;
startPause = 'P';
}while((startPause == 's') || (startPause =='S'));
}
cout<<"End!\nLED is Off";
return 0;
}
void manualMode(){
cout<<"Enter Temperature: \n";
cin>>temp;
cout<<"Enter Time to wash: \n";
cin>>timeToWash;
cout<<"Choose Operation: (1)Water Only, (2)Water and Soap, (3)Rinse, (4)Dry, (5)All\n";
cin>>operation;
}
void defaultMode(){
int whatToWash;
cout<<"Choose what to Wash: (1)Cups, (2)Plates, (3)Pots";
cin>>whatToWash;
switch(whatToWash){
case 1:
temp = 30;
timeToWash = 3;
break;
case 2:
temp = 40;
timeToWash = 3;
break;
case 3:
temp = 60;
timeToWash = 3;
break;
}
}