Devices & Components
Arduino Uno Rev3
Buzzer
Resistor 220 ohm
Jumper wires (generic)
Cable, Serial Converter Programming
5 mm LED: Red
Resistor 10k ohm
General Purpose Transistor NPN
Software & Tools
Arduino IDE
Project description
Code
Water Sensor
arduino
You upload it to your Arduino and then touch the two prongs. Make sure to check your serial monitor.
1const int Buzzer = 5; //Buzzer pin 2const int led = 6; //Led pin 3const int watersensor = 7; //Water Sensor pin 4int watersensorstate = 0; //State of the water sensor 5// setup (intializes everthings) 6void setup() { 7pinMode(led, OUTPUT); //set the Led as an output 8pinMode(Buzzer, OUTPUT); //set the buzzer as an output as well 9pinMode(watersensor, INPUT); //set the water sensor as an input 10Serial.begin(9600);//Start the serial connection 11} 12//loop (Does the actual program) 13void loop() { 14 watersensorstate = digitalRead(watersensor); 15 //Set the water sensor state as either high depending on the water sensor 16 //if it senses water it will turn on the led, pulse the buzzer, and say "Water Detected" 17 if(watersensorstate==1){ 18 digitalWrite(led, HIGH); 19 digitalWrite(Buzzer, HIGH); 20 delay(150); 21 digitalWrite(Buzzer, LOW); 22 delay(150); 23 Serial.println("Water Detected"); 24 } 25 //otherwise it will do nothing and say "No water Detected" 26 else{ 27 digitalWrite(led, LOW); 28 digitalWrite(Buzzer, LOW); 29 Serial.println("No water Detected"); 30 } 31} 32
Downloadable files
Water Sensor
It won't work but you need it for the connections
Water Sensor

Water Sensor
It won't work but you need it for the connections
Water Sensor

Comments
Only logged in users can leave comments