//#include #include LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display // initialize the library by associating any needed LCD interface pin // with the arduino pin number it is connected to //float calibration_value = 21.34; float calibration_value = 28.62; int phval = 0; unsigned long int avgval; int buffer_arr[10],temp; int t_sens = 1; // analog pin 1 int val_t ; float temper; void setup() { lcd.init(); // initialize the lcd lcd.backlight(); Serial.begin(9600); lcd.begin(20, 4); pinMode(t_sens,INPUT); } void loop() { for(int i=0;i<10;i++) { buffer_arr[i]=analogRead(0); delay(30); } for(int i=0;i<9;i++) { for(int j=i+1;j<10;j++) { if(buffer_arr[i]>buffer_arr[j]) { temp=buffer_arr[i]; buffer_arr[i]=buffer_arr[j]; buffer_arr[j]=temp; } } } avgval=0; for(int i=2;i<8;i++) avgval+=buffer_arr[i]; float volt=(float)avgval*5.0/1024/6; float ph_act = -5.70 * volt + calibration_value; //temperature sensor val_t=analogRead(t_sens); temper = val_t * 5.0/1024*49; // Serial.print("volt value :"); // Serial.print(val); Serial.print("Temperature :"); Serial.print(temper); Serial.print(" PH :"); Serial.println(ph_act); // Serial.println(volt); lcd.setCursor(0, 0); lcd.print("pH Val :"); lcd.setCursor(8, 0); lcd.print(ph_act); lcd.setCursor(0, 1); lcd.print("Temp(C):"); lcd.setCursor(8, 1); lcd.print(temper); lcd.setCursor(6, 3); lcd.print("Iwan-FA2022"); delay(1000); }