#include <Wire.h>
#include <LiquidCrystal_I2C.h>

const int pressurePin = A1;
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.clear();
  lcd.backlight();
}

void loop() {
  unsigned long startTime = micros();  // Start time of the loop

  for (int i = 0; i < 100; i++) {
    int rawValue = analogRead(pressurePin);
    float millibars = map(rawValue, 0, 1023, 0, 2000) / 10.0;

    // Display the value on the LCD
    lcd.setCursor(0, 0);
    lcd.print("Pr: ");
    lcd.print(millibars);
    lcd.println(" mbar ");

    // Display the value in the serial monitor
    Serial.print("Pr: ");
    Serial.print(millibars);
    Serial.println("  mbar ");

    // Delay to control the sampling rate
    delayMicroseconds(10000);  // 10,000 microseconds delay for approximately 100 samples per second
  }

  unsigned long endTime = micros();  // End time of the loop

  // Calculate the time taken by the loop
  unsigned long loopTime = endTime - startTime;

  // Subtract the loop time from the desired delay time to maintain the desired sampling rate
  unsigned long delayTime = 10000 - loopTime;

  if (delayTime > 0) {
    delayMicroseconds(delayTime);
  }
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
lcd:GND
lcd:VCC
lcd:SDA
lcd:SCL