I am new to hardware of electronics. I have an Ardunio 2 module relay switch and a Arduino Uno USB Microcontroller Rev 3. I will have about a clear PVC pipes attached with automatic shut off valve and a contamination sensor. For the contamination sensor I will use a LDR with a LED light that will shine on it. When it senses contamination, I want the relay switch to cut off the valve and stop water flow. Im still in the beginning stages of the project I just need to get the basics down.
Can anyone help???
The relay module should have 4 pins, VCC (+), relay1, relay2, and GND (-). Connect VCC and GND directly to the 5V and ground pins on the Uno. Connect the relay1 and relay2 pins to Uno digital pins of your choosing. When writing your code, configure those ports as OUTPUTs. Do a digitalwrite HIGH to them when you want to switch the relays on.
I do not recommend an LDR -- they have very slow response times. If your contamination flits through the pipe quickly, you could miss it. A phototransistor would be a lot better, see 3. Connect a phototransistor to Arduino - The Robotronics.
From there you run in a loop sampling the analog pin and writing your digital pins LOW when the value reaches some threshhold (you'll need to do some testing to see what that threshhold is).
Please note that if your relays are switching mains / line voltage (110VAC-240VAC) you should take appropriate safety precautions due to the danger of death or fire.