Salinity detection project

Hey there I am new to these forums and I hope I am not posting in the wrong place. In any case I recently bought an Arduino Uno startup kit. The project I am working on is a salinity detection system. I want my system to detect a voltage difference across a resistor that is in parallel to an open circuit submerged in water (two nails spaced about 1 cm apart). What I would like to be able to do is send the voltage readings to a data processor so that I can graph the voltage change over time as I add fresh water into the salty water. I was going to use an open-source program called Processor to do this, does anyone know if processor will work for this?

Regardless, currently I am experimenting and I dont have a salinity detector yet so instead I am using a photo-resistor. Currently I am reading values into the serial monitor and here is what I need to know.. this value I am seeing.. what is it? Here is my code:

int val = 0; // variable to store value read at analog pin 3

void setup(){
  Serial.begin(9600); // set up to pring out text to monitor, baud rate = 9600
  pinMode(11,OUTPUT); // declare pin 11 as an output
}

void loop(){
  val = analogRead(3); // read analog input pin 3
  Serial.println(val); // pring value to serial monitor

  // if statement used to control LED
  if(val<600){
      digitalWrite(11,HIGH); 
      delay(100);
      digitalWrite(11,LOW); 
      delay(100);
  }
}

I have an led setup so that I could tell if the thing was working without understanding the values being printed into the serial monitor. I see that the value increases as the light seen by the pr decreases but as to the actual value that I am seeing I dont know how its calculated. It varies between 500 (full light) and around 700 (no light). Is this value somehow the voltage I am looking for? Or do I need to re-wire my circuit?

Here is my circuit:

The code that I see does not output to the serial monitor.
The circuit is not visible to me.

Your problem is the LED and resistor connected to the same pin as you're measuring the analog voltage on. That will throw things off. Put the LED on a different pin.

And that you incorrectly attached the image.

The value you get from analogRead() is the voltage on the pin you specified, in 1024'th's of the reference voltage (which is the operating voltage, 5v, by default). 512 = 2.5v, and so on.

How do I put the LED on a different pin without removing it from the circuit? I have another question as well. Why is it that I can disconnect the 5v rail and the circuit will still operate?

anyone?

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

If you use REPLY rather than QUICK REPLY, you will see it has an ATTACHMENTS facility.
You first attempt did not link.

Thanks.. Tom.... :slight_smile:

Just remove the LED from the circuit shown in DrAzzy's post. Its the PR in series with a resistor and I a m measuring at the node in-between the resistor and the PR.