#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd (12, 11, 10, 9, 8, 7);
byte a[]={ B00000,B00000,B00000,B00000,B00000,B00000,B00000,B11111};
byte b[]={ B00000,B00000,B00000,B00000,B00000,B00000,B11111,B11111};
byte c[]={B00000,B00000,B00000,B00000,B00000,B11111,B11111,B11111};
byte d[]={B00000,B00000,B00000,B00000,B11111,B11111,B11111,B11111};
byte e[]={B00000,B00000,B00000,B11111,B11111,B11111,B11111,B11111};
void Intro();
void Cautions();
void Display_results();
void oxygen();
int oxyg=3;
void setup() {
pinMode(oxyg,INPUT);
Serial.begin(9600);
lcd.begin(20,4);
lcd.createChar(1, a);
lcd.createChar(2, b);
lcd.createChar(3, c);
lcd.createChar(4, d);
lcd.createChar(5, e);
}
void loop() {
Intro();
delay(10000);
lcd.clear();
Cautions();
delay(10000);
lcd.clear();
for(int i=0; i<120; i++){
delay(500);
Display_results();
oxygen();
}
lcd.clear();
}
void Intro(){
lcd.setCursor (0, 0);
lcd.print ("AHMED MEDIX LIFECARE");
lcd.setCursor (3, 1);
lcd.print ("PAKISTAN NO.1");
lcd.setCursor (0, 2);
lcd.print ("(ISO 9001)AMBULANCES");
lcd.setCursor (0, 3);
lcd.print ("SERVICES 04235213441");
}
void Cautions(){
lcd.setCursor (0, 0);
lcd.print ("FOR ELE FAULT ALWAYS");
lcd.setCursor (3, 1);
lcd.print ("CHECK FUSE BOX");
lcd.setCursor (1, 2);
lcd.print ("KEEP 02 CYL CLOSE");
lcd.setCursor (2, 3);
lcd.print ("WHEN NOT IN USE");
}
void Display_results(){
int Bt_1;
int Bt_2;
int Temp_c;
float Battery_1;
float Battery_2;
int temprature;
int oxygen=3;
lcd.setCursor (0, 0);
lcd.print ("BATT(1)");
lcd.setCursor (0, 1);
lcd.print ("BATT(2)");
lcd.setCursor (0, 2);
lcd.print ("TEMPRATURE");
Bt_1 = analogRead (A4);//(A4);
Battery_1 = Bt_1 * (15.8 / 1023.0);// 3.82 = 781.571 * 15.8/1023 =12.07
lcd.setCursor (7, 0);
lcd.print (Battery_1);
lcd.print ("V");
Serial.print(Battery_1);
lcd.setCursor (13, 0);
if(Bt_1 >170)
{lcd.print(char(1));}
else
{lcd.print(" ");}
if(Bt_1 >340)
{lcd.print(char(2));}
else
{lcd.print(" ");}
if(Bt_1 >510)
{lcd.print(char(3));}
else
{lcd.print(" ");}
if(Bt_1 >680)
{lcd.print(char(4));}
else
{lcd.print(" ");}
if(Bt_1 >850)
{lcd.print(char(5));}
else
{lcd.print(" ");}
Bt_2 = analogRead (A3);//(A3);
Battery_2 = Bt_2 * (15.8 / 1023.0);
lcd.setCursor (7, 1);
lcd.print (Battery_2);
lcd.print ("V");
lcd.setCursor (13,1);
if(Bt_2 >170)
{lcd.print(char(1));}
else
{lcd.print(" ");}
if(Bt_2 >340)
{lcd.print(char(2));}
else
{lcd.print(" ");}
if(Bt_2 >510)
{lcd.print(char(3));}
else
{lcd.print(" ");}
if(Bt_2 >680)
{lcd.print(char(4));}
else
{lcd.print(" ");}
if(Bt_2 >850)
{lcd.print(char(5));}
else
{lcd.print(" ");}
Temp_c = analogRead (A5);//(A5);
temprature = (Temp_c /2.5);//(Temp_c * 100)
lcd.setCursor (15, 2);
lcd.print (temprature);
lcd.print (" C");
}
void oxygen(){
int val = digitalRead(oxyg);
lcd.setCursor (2,3);
{if (val == LOW)
{lcd.print ("OXYGEN IN USE");
} else {
for (int j=0; j<10; j++);{
lcd.print ("CHECK OXYGEN CYL");
delay (300);
lcd.setCursor (2,3);
lcd.print (" ");}
} }
}