Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float calibration = 21.24;
- const int analogInPin = A1;
- int sensorValue = 0;
- unsigned long int avgValue;
- float b;
- int buf[10],temp;
- void setup() {
- analogReference(DEFAULT);
- Serial.begin(9600);
- }
- void loop() {
- for(int i=0;i<10;i++)
- {
- buf[i]=analogRead(analogInPin);
- delay(30);
- }
- for(int i=0;i<9;i++)
- {
- for(int j=i+1;j<10;j++)
- {
- if(buf[i]>buf[j])
- {
- temp=buf[i];
- buf[i]=buf[j];
- buf[j]=temp;
- }
- }
- }
- avgValue=0;
- for(int i=2;i<8;i++)
- avgValue+=buf[i];
- float pHVol=(float)avgValue*4.5/1000/6;
- Serial.print("phvol = ");
- Serial.println(pHVol);
- float phValue = -5.70 * pHVol + calibration;
- Serial.print("sensor = ");
- Serial.println(phValue);
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement