Hello all, here we have implemented a water existence indicator. When the sensor is immersed into water, the Green LED starts glowing and the buzzer starts producing one type of sound. When the sensor is removed out of water and dried off the Red LED glows and the buzzer starts producing a different kind of sound. A small demo of this project is shown in the below clip.
The circuit diagram for the project is given below. Let me explain the circuit diagram. We are using Arduino UNO microcontroller to drive the whole circuit. As we mentioned above, we are using RED and GREEN LEDs for two different purposes. The anode (the longer leg) of the RED LED is connected to pin number 4 of Arduino, while cathode (the shorter leg) of RED LED is connected to ground of Arduino. The anode of the GREEN LED is connected to pin number 7 of Arduino while the cathode is connected to ground of Arduino. Each LED has a resistance connected in series with it. (Unfortunately I tend to forget the value of resistance while writing this article, however a resistance of value 1K would be a good choice to reduce the current flowing through the LEDs in their ON state... and avoid burning of the LEDs)
We are using passive buzzer to produce two different sounds (melodies), one melody is played when the sensor is in dry environment. While the other is played when the sensor is in wet environment. The polarities of the buzzer are indicated near the two pins of the buzzer. The positive pin goes to pin number 13 of Arduino and the negative pin goes to ground of Arduino. We have displayed an image with the buzzer polarities below the circuit diagram. We request you to please check it before making connections.
We are using water level indicator sensor, just to check the presence of water (we are not actually measuring the 'water level'). The '+' and the '-' of the sensor goes to Vcc and GND of Arduino respectively. While the 'S' (stands for signal) pin of the sensor goes to pin number 6 of Arduino.
NOTE: We connect Arduino Uno to laptop, which acts as a +5V power source.
A functioning CPP code for this demo is shared below. Please upload it in Arduino IDE and test the circuit. Let me explain the code to a certain extent. We have included the header file pitches.h to have different melodies to play. In the next few lines, we have defined the pin numbers which we are using over Arduino board. As we all know the Arduino code is divided into two distinct parts "Setup" and "Loop". The "Setup" code gets executed only once during the program life-cycle. So we have put all the initialization code over there. We are defining pin 7 and 4 as OUTPUT pins, which is required for LEDs to function. The "Loop" part of the code runs repeatedly. Here, we want to perform analog read on pin number 6 (which is the Signal pin of water level sensor). If the value we receive is greater than 250 (which means the sensor sensed water), we make GREEN LED ON, by writing HIGH on pin 7. We also play tone NOTE_B0 on sensing water. However, if the value we receive is less than 250 (which means the sensor is dry), we make RED LED ON, by writing HIGH on pin 4. We simultaneously make the other LED LOW, which makes it turn OFF. And we play tone NOTE_DS8. We have put the sensor reading code in Loop, just because we can perform the water sensing experiment multiple times.
NOTE: We arrived at the value of 250 for sensing wetness, by actually immersing the sensor in the water and calibrating it.
References
No comments:
Post a Comment