How to connect a 2 module relay switch to a microcontroller

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 https://sites.google.com/site/therobotronics/arduino/connect-a-phototransistor-to-arduino.

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.