// void setup(){
//   Serial.begin(9600);
// }

// void loop(){
//   int read_adc = analogRead(A0);
//   float voltage = read_adc * (5.0 / 1023.0);
//   Serial.print("Voltage V: ");
//   Serial.print(voltage);
//   Serial.println();

//   float current_millis = (voltage / 250) * 1000;
//   Serial.print("Current mA: ");
//   Serial.print(current_millis);
//   Serial.println();

//   // convert millis into sensor value
//   float sensor_value_mgl = (current_millis - 4) / 0.5;
//   Serial.print("Sensor Level: ");
//   Serial.println(sensor_value_mgl);
//   delay(500);
// }


#define REFERENCE_INPUT_VOLTAGE   5.0            // 5VDC
#define RESISTOR_VALUE            250            // 250 Ohm 1W
#define SENSOR_PH_PIN             A0
#define ANALOG_RESOLUTION         1023

#define PH_MIN_VALUE 0
#define PH_MAX_VALUE 14

void setup() {
  Serial.begin(9600);
}

void loop() {
  int read_adc = analogRead(SENSOR_PH_PIN);  // 10-bit resolution
  float reading_voltage = read_adc * (REFERENCE_INPUT_VOLTAGE / ANALOG_RESOLUTION);
  float reading_current_millis = (reading_voltage / RESISTOR_VALUE) * 1000;
  Serial.print("Millis: ");
  Serial.println(reading_current_millis);

  float proportion = (reading_current_millis - 4.0) / (20.0 - 4.0);
  float sensor_value = PH_MIN_VALUE + proportion * (PH_MAX_VALUE - PH_MIN_VALUE);
  Serial.println(sensor_value);
  delay(500);
}
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
pot1:GND
pot1:SIG
pot1:VCC