#include <LiquidCrystal_I2C.h> // if you don´t have I2C version of the display, use LiquidCrystal.h library instead
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
int tempo; //to store the millis() function
int rd_tm = 500; //[ms] to set time of reading
int lettura[] = {0 , 0}; // variable to read the first sensor
float volt = 0;
float pressure = 0;
int i = 0;
//support variable
bool debug = 0; //For print more info in the serial port
bool display = 1; //To print on diplay
void setup() {
Serial.begin(115200);
Serial.print("--Setup--");
pinMode(A0,INPUT);
//Set up
Serial.print("\n\n--interface printing--");
Serial.print("\n\n----------TRASDUINO-----------");
}
//this function convert the value readed by the analog port to the corrispondent voltage value
float readToVolt(int read, float scale)
{
if(debug)
{
Serial.print("| |scale -> ");
Serial.print(scale);
}
float volt = read*scale;
Serial.print("| |Volt -> ");
Serial.print(volt);
return volt;
}
//this function convert the Voltage value in Bar (linear correlation)
float VoltToBar(int volt)
{
float Bar = volt*35 -32.97; //empirical relation for the sensor
Serial.print("| |Bar -> ");
Serial.print(Bar);
return Bar;
}
void loop()
{
//start
tempo = millis();
lettura[0] = analogRead(A0); // if you want to conect the sensor to other port use this variable
lettura[1] = analogRead(A1); // if you want to conect the sensor to other port use this variable
i = 0;
while( i < 2)
{
Serial.print("\n Sensor(");
Serial.print(i+1);
Serial.print(") :");
if (debug)
{
Serial.print("\n\n time ->");
Serial.print(tempo);
Serial.print("| |read ->");
Serial.print(lettura[i]);
}
else
{
Serial.print("\n\n");
}
i ++;
}
delay(rd_tm);
}