XRAD'S simple digital switch, need help with component design...

XRAD

Well-known member
I am trying to build a water sensor with the design in the image below (JUST the high water sensor). I have substituted a 2n3904 for the BC548C (because I don;t have any of these). I thought they were similar enough to work...but...no luck.

I want the RED led to come on when water is sensed(the boiler 'pins' are in contact). Pins changed for teensy 3.2

Any suggestions? Is there an easier way? the Base probe is going into a mini boiler....

right now with current design, the LED blinks on set-up, and then stays on...whether or not the boiler probes are in contact with water....


Code:
#define sensorPin 23
#define ledPin 3

void setup() {
  pinMode(sensorPin , INPUT);
  pinMode(ledPin , OUTPUT);
  digitalWrite(ledPin , HIGH);
  delay(3000);
  digitalWrite(ledPin , LOW);
  delay(1000);
}

void loop() {
  if (analogRead(sensorPin == LOW)) {
    digitalWrite(ledPin , HIGH);
  } else {
    digitalWrite(ledPin , LOW);
  }
}
 

Attachments

  • water level arduino simple.jpg
    water level arduino simple.jpg
    79.5 KB · Views: 32
LOL ....... :)
HIGH and LOW are used for DIGITAL input and output NOT ALALOGUE!!
Your answer has absolutely nothing to do with "if (analogRead(sensorPin == LOW)) { ..."

Then: What's the difference of a digital zero and a analog zero? Hm.... Must be something new? ;-)

#define LOW 0
.

So, is that digital or analog?

And, let us know your opinion, what does (sensorPin == LOW) mean?
And what is LOW + HIGH? ;)
And what is (LOW == HIGH) ?
 
LOL ....... :)

Your answer has absolutely nothing to do with "if (analogRead(sensorPin == LOW)) { ..."

Then: What's the difference of a digital zero and a analog zero? Hm.... Must be something new? ;-)

#define LOW 0

So, is that digital or analog?

And, let us know your opinion, what does (sensorPin == LOW) mean?
And what is LOW + HIGH? ;)
And what is (LOW == HIGH) ?
  • So, is that digital or analog? It's a definition of a text substitution you want the compiler to make. Use it as you see fit.
  • What's the difference of a digital zero and a analog zero? Well ... you can compare digital zero with ==, but analogue should probably use an inequality
  • what does (sensorPin == LOW) mean? Who knows? the result will be either true or false, though
  • And what is LOW + HIGH? ;) based on the above #define, it's HIGH
  • And what is (LOW == HIGH) ? false
This is fun; hold on a sec while I get my popcorn

Oh, and
if (analogRead(sensorPin == LOW)) {
isn't nonsensical, but it's probably not what you meant to do: the first closing bracket is probably in the wrong place (should be before the ==), and if it's analogue you might want to consider using < THRESHOLD, it might never equal zero.
 
  • So, is that digital or analog? It's a definition of a text substitution you want the compiler to make. Use it as you see fit.
Correct, great.
  • What's the difference of a digital zero and a analog zero? Well ... you can compare digital zero with ==, but analogue should probably use an inequality
Does not matter here.. but a zero is a zero.
  • what does (sensorPin == LOW) mean? Who knows? the result will be either true or false, though
Correct, great. Eh. Not great. SensorPin has a value, which you can find in this thread.

  • And what is LOW + HIGH? ;) based on the above #define, it's HIGH
Correct, great.
  • And what is (LOW == HIGH) ? false
Correct, great. Let me extend this: What is the value of false, here, assuming analogRead does not take a bool as parameter?
This is fun; hold on a sec while I get my popcorn

Oh, and

isn't nonsensical, but it's probably not what you meant to do
[/LIST]
h4yn0nnym0u5e, it would be better to read a bit more from this thread before answering. ;-) I meant nothing..
 
thank you for replies! I tried digitalread as well. Did not work. I am really looking for any schematic corrections to the wiring dgm or ideas for another way to sense the 'contact circuit'.....or a better way to build the HIGH /LOW sensor circuit for the teensy to 'sense'....
 
Water is not conductive unless it has impurities. My well water is very hard, and some water in the sink has about 100k ohms resistance between probes about 6 inches apart. You could measure your setup to see what kind of resistance the circuit needs to measure. You may need to adjust the 470 ohm load resistor to higher values depending upon how much base current you can produce.
 
Back
Top