#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD

LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);

uint8_t buzzerPin = 2;
uint8_t inputPin = A0;
uint8_t lcdWidth = 16;

void setup() {
  lcd.init();
  lcd.backlight();
  pinMode(inputPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  uint32_t inputValue = analogRead(A0);
  uint32_t soundFrequency = (inputValue * 10000) / 1023 + 100;
  tone(buzzerPin, soundFrequency);
  lcd.setCursor(5,0);
  lcd.print(inputValue * 5000 / 1023);
  lcd.print(" mV");
  lcd.setCursor(0,1);
  for (uint8_t i = 0; i < inputValue * lcdWidth / 1023; ++i) {
    lcd.print("=");
  }
}