
CODE
int stepPin=3;
int dirPin=4;
volatile char choice;
//Function PrototypeS
void infant();
void toddler();
void adult();
void setup() {
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
Serial.begin(9600);
}
void loop(){
Serial.println("Please Select The Desired Mode Given in the DASHBOARD, By Pressing The Corresponding Label:\n");
Serial.println("*****DASHBOARD******");
Serial.println(" >> I:INFANT ");
Serial.println(" >> T:TODDLER ");
Serial.println(" >> A:Adult");
Serial.println(" >> S: Stop the Ventilator \n");
while (Serial.available() == 0) {
// Wait for User to Input Data
}
choice= Serial.read();//Read the data the user has input
switch(choice)
{
case 'I':
//infant();
Serial.println("You are in Infant Mode");
break;
case 'T':
while(choice!='S'){
Serial.println("You are in Toddler Mode");
// toddler();
}
break;
case 'A':
Serial.println("You are in Adult Mode");
// adult();
break;
case 'S':
Serial.println("Ventilator Has Been Sttoped");
break;
default:
Serial.println("Invalid Input");
while (Serial.available() == 0) {
// Wait for User to Input Data
}
choice= Serial.read();////Read the data the user has input
}}
void infant(){
run(1600,1000,150,250,325);
}
void toddler()
{
run(1600,1000,250,250,500);
}
void adult()
{
run(1000,1000,250,250,1000);
}
void run(int x,int y,int z,int k,int l){
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int i = 0; i
delayMicroseconds(z);
digitalWrite(stepPin,LOW);
delayMicroseconds(k);
}
delay(l); // One second delay
digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int j = 0; j
delayMicroseconds(z);
digitalWrite(stepPin,LOW);
delayMicroseconds(k);
}
delay(1); }