Problem with my codes, pH sensor and buzzer alarm

int analogInPin = A0; 
int buzzerPin = 8;

void setup()
{
pinMode (buzzerPin,OUTPUT);// set buzzer as an output
pinMode (analogInPin,INPUT);//set ph sensor as an input
 Serial.begin(9600);//start serial port at 9600 bauds
}

void loop() 
{
int sensor =analogRead(A5); // read the ph sensor
 Serial.println (A5);// print the value of the ph sensor to the serial monitor

if ((A5 < 6.5) && (A5 > 9.0)) {
  digitalWrite(8,HIGH); // if the ph sensor senses too low or too high ph level, turn the buzzer on
    tone (8, 5000);
 }
 
else ((A5 > 6.6)); {
  digitalWrite (8,LOW);// if the ph sensor senses normal ph level, turn the buzzer off
  tone (8, 0);
}
}
if ((A5 < 6.5) &

A5 has the value 19, on a Uno,IIRC

else ((A5 > 6.6));

Oops

int sensor =analogRead(A5); // read the ph sensor into a variable called sensor
 Serial.println (sensor);// print the value of the sensor variable to the serial monitor

Hope this helps

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.