#include <LiquidCrystal_I2C.h>
#define SENSOR A0
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
lcd.setCursor(5,0);
lcd.print("H15 Pharos");
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
lcd.init();
lcd.backlight();
float psi = 1.0;
float voltage =1.0;
int adcVal = 0;
adcVal = analogRead(SENSOR);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
voltage = adcVal*5/1024.0;
psi = 50*voltage-25;//
// print out the value you read:
Serial.print("Voltage: ");
Serial.println(voltage);
Serial.print("PSI: ");
Serial.println(psi);
//map(value, fromLow, fromHigh, toLow, toHigh)
float out2 = map(adcVal, 102.4, 920.6, 0.0, 200.0);
Serial.print("Mapped: "); Serial.println(out2);
lcd.setCursor(0,0);
lcd.print("Voltage: ");
lcd.print(voltage);
lcd.setCursor(0,1);
lcd.print("PSI: ");
lcd.print(psi);
}