/* Author: Danny van den Brande, Arduinosensors.nl. BlueCore Tech. This code is very simple and made for a flood alarm, can be used anywhere to detect water. it simply reads a boolean value of 1 or 0. You cannot use this code for Water level monitoring. I would not used this sensor anyway for water level measuring unless it was gold coated, but they are great to use as a alarm. I do not sell them on my website because they wont last long. I tested it in a glass of water and the metal disapears. I just made this example so people can actually use this pretty bad sensor. I will order some gold coated ones which are new on the market from a new supplier who has delivered me only good stuff recently, i will test them and see if they are qood quality and useful for long term water level measuring without breaking apart within a few days. */ int WaterAlarm = 2; int Buzzer = 9; int Led = 10; boolean val; //simply reads 1 or 0 as a value 1 when detecting water // here i set up the tones, you can change them @ void loop. int tones[] = {261, 277, 293, 311, 329, 349, 369, 392, 415, 440, 466, 493, 523 ,554}; // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // You can add more tones but i added 14. Just fill in what tone you would like to use, @ void loop you see " tone(Buzzer, tones[12]); " below, digitalWrite(Buzzer, HIGH); // here you can change the tones by filling in a number between 1 and 14 void setup() { Serial.begin(9600); pinMode (WaterAlarm, INPUT); pinMode (Buzzer, OUTPUT); pinMode (Led, OUTPUT); } void loop() { val = digitalRead(WaterAlarm); if (val == 1) { digitalWrite(Led, HIGH); digitalWrite(Buzzer, HIGH); tone(Buzzer, tones[6]); delay(200); digitalWrite(Led, LOW); digitalWrite(Buzzer, LOW); noTone(Buzzer); delay(200); digitalWrite(Led, HIGH); digitalWrite(Buzzer, HIGH); tone(Buzzer, tones[14]); delay(200); digitalWrite(Led, LOW); digitalWrite(Buzzer, LOW); noTone(Buzzer); delay(200); } else { digitalWrite(Led, LOW); digitalWrite(Buzzer, LOW); } }