/* # This sample code is used to test the pH meter V1.0. # Editor : YouYou # Ver : 1.0 # Product: analog pH meter # SKU : SEN0161 */ //#define SensorPin A0 //pH meter Analog output to Arduino Analog Input 0 #define Offset 0.07 //deviation compensate int analogPin = A1; int value = 0; void setup(void) { // pinMode(LED,OUTPUT); Serial.begin(9600); Serial.println("pH meter experiment!"); //Test the serial monitor pinMode(A1,INPUT); } void loop(void){ float pHValue; float voltage; voltage=analogRead(analogPin)*5.0/1024; Serial.print(voltage,5); pHValue = 0.1196836333*pow(voltage, 6.2034289432)+Offset; Serial.print("Voltage:"); Serial.print(" pH value: "); Serial.println(pHValue); delay(2000); }