#include #include // Set the LCD address to 0x27 for a 16 chars and 2 line display // If it doesn't work, try the address 0x3F. There are scripts online to dump the list // of connected I2C devices (just google them), which will help you. LiquidCrystal_I2C lcd(0x27, 16, 2); void setup() { // initialize the LCD lcd.begin(); // Turn on the blacklight and print a message. lcd.backlight(); lcd.setCursor(0,1); lcd.print("Initializing..."); } void loop() { char mybuffer1[16]; // working variable char mybuffer2[16]; // working variable // ========= 1) read value on pin ============ float FS = 10; // [Torr] (full scale) int gauge_value_int = analogRead(A0); // read value from baratron float gauge_value_float = gauge_value_int/1023.0; // cast value to float going from 0 to 1 float Volt = gauge_value_float*5; // voltage float press_Torr = gauge_value_float*FS; // find the pressure, in Torr float press_Pa = press_Torr * 133.322; // ========= 2) write on LCD display ============ char str1[15]; char str2[15]; dtostrf(press_Torr,5,3,str1); dtostrf(press_Pa,5,2,str2); sprintf(mybuffer1,"%s [Torr]", str1); sprintf(mybuffer2,"%s [Pa]", str2); lcd.clear(); lcd.setCursor(0,0); lcd.print(mybuffer1); lcd.setCursor(0,1); lcd.print(mybuffer2); delay(400); }