In: Computer Science
Using arduino 1 In a certain chemical processing plant, a liquid chemical element is used in a manufacturing process. This chemical element is stored in three different tanks. A level sensor in each tank according to the figure generates a HIGH level voltage when the liquid level in the tank falls below 25%. Design a circuit with Arduino to monitor the level of the chemical element that will trigger an alarm when the level of AT LEAST 2 tanks drops below 25%. Note: Simulate the sensors with switches or cables connected directly to 5V or Ground and the alarm with an LED. and make a flow chart
Note : check attached image for output and program .Schematic designed in Proteus and Flow chart in Paint.
Schematic :
FlowChart :
Program :
const int LED= 2; //Pin LED
int button1=3; //switch Pin
int button2=4;
int button3=5;
int buttonStatus=0;
int switchFlag1=0;
int switchFlag2=0;
int switchFlag3=0;
void setup()
{
pinMode(LED, OUTPUT); //set OUTPUT to LED PIn
pinMode(button1, INPUT); //set INPUT to switch pin
pinMode(button2, INPUT);
pinMode(button3, INPUT);
delay(100);
}
void loop()
{
buttonStatus = digitalRead(button1); //read button 1 status
if (buttonStatus == HIGH)
switchFlag1=1; //set flag
else
switchFlag1=0;
buttonStatus = digitalRead(button2); //read button 2 status
if (buttonStatus == HIGH)
switchFlag2=1;
else
switchFlag2=0;
buttonStatus = digitalRead(button3); //read button 3 status
if (buttonStatus == HIGH)
switchFlag3=1;
else
switchFlag3=0;
if(switchFlag1==1 && switchFlag2==1) //if tank1 and tank 2
have less than 25%
{
digitalWrite(LED,HIGH);
switchFlag1=0;
switchFlag2=0;
switchFlag3=0;
}
else if(switchFlag1==1 && switchFlag3==1) //if tank1 and
tank 3 have less than 25%
{
digitalWrite(LED,HIGH);
switchFlag1=0;
switchFlag2=0;
switchFlag3=0;
}
else if(switchFlag2==1 && switchFlag3==1) /if tank 2 and
tank 3 have less than 25%
{
digitalWrite(LED,HIGH); //set led high
switchFlag1=0; reset flag of switch
switchFlag2=0;
switchFlag3=0;
}
else //no one than set led low
{
digitalWrite(LED,LOW);
switchFlag1=0;
switchFlag2=0;
switchFlag3=0;
}
delay(1000);
}