Grumpy_Mike:
Yes but make it a dotted line. The resistors in those LEDs are a bit low though and as a result, the LED takes too much current.
Thanks for the sensor link. A resistor value of 100R is too low, you need something in the 240 to 1K range.
Why are you using the analogue output when the sensor has a digital output? Why? Because as I said:-
"With a transistor, you will need a resistor in the base as well as in series with the LED in the collector."
If you are getting more than 0.7V from the analogue output when it is dry then the LED will stay permanently on. If you want to use the analogue output then you will have to measure the range of voltages you get out, and arrange a potential divider to cut down the output produces a voltage between zero and 1.4V giving you a threshold of 0.7V.
If you are using an RGB LED then why was this not shown in the diagram? When you draw a schematic it is supposed to represent what you have, if you start showing what you don't have then how on earth is anybody supposed to give you accurate advice?
So how its this wired up? If you want a white output you need three resistors on that LED. A picture of an LED is about as useful as a chocolate teapot. You can't tell by looking if it is the common anode or common cathode?
I don't know why you are not using the digital output? If you have tried it and it didn't work did you add the pull-up resistor shown as R5 on the schematic in the datasheet you linked to? Note the resistor values in that datasheet, they use 1K for the LED's current limiting resistor. If you wire the digital output like the schematic in the datasheet it should work the right way round.
I checked the voltage output from the Analog pin of the sensor and it is 4.99~5V and when I drop water on the sensor the voltage drops to 0.10-0.12V. I then checked the voltage on the digital pin it was 0.10-0.12V with and without water on the sensor. I was not able to check current because my multimeter is broken and it just checks voltage, resistance, and connectivity. I tried using a 200ohm resistor at the base and the LED side still not effective and I tried using the resistor of 1K still same for analog output pin.
As you said, "f you want to use the analog output then you will have to measure the range of voltages you get out, and arrange a potential divider to cut down the output produces a voltage between zero and 1.4V giving you a threshold of 0.7V."
I have to create this and it will add more components to the application and I wanted to create with a limited component as possible.
Can you please explain to me how can I get that Digital output to turn on and off at least an LED?
I have connected the digital output pin to the cathode of LED(Now I am using a simple LED) and connected LEDs anode to the ground and I used a 200-ohm resistor and also replaced it will 1K. And supplied 5V and GND to the sensor. There was no changes in LED it was turned off. I even dropped water on the sensor still turned off. I tried the same with the transistor.