int buzzPin=8;
int buzzTime=1;
int buzzTime2=800;
const int waterSens = A0;
//int segPD = ;
int waterVal;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(waterSens, INPUT);
pinMode(buzzPin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
waterVal = analogRead(waterSens); //read the water sensor
Serial.println(waterVal); //bb the value of the water sensor to the serial monitor
if (waterVal >= 200){
digitalWrite(buzzPin,HIGH);
delayMicroseconds(buzzTime2);
digitalWrite(buzzPin,LOW);
delayMicroseconds(buzzTime2);
}
else{
digitalWrite(buzzPin,LOW);
delayMicroseconds(buzzTime2);
digitalWrite(buzzPin,LOW);
delayMicroseconds(buzzTime2);
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(5);
}
}
Comments
Please log in or sign up to comment.