/* OPTICAL WATER LEVEL SENSOR - The optical sensor is great as there are no moving parts like all other water floats. Very accurate and nice little sensors. I could not find any information how to get these to work, after some research i found these have an LED and a LDR light sensor, NICE! the LED is on the blue and red wires blue to +5 VCC then to a 390R resistor, red to GND. The white and yellow are the LDR. White is +5 VCC, yellow to A0 pin on UNO and also yellow to 4.7K resistor then to GND. There is no need for any settings in the code for the LED as its taking direct power from +5 VCC. You could use a digital pin i guess and set it high for +5 to LED and LDR. Code by Scott Bailey www.activstudios.com */ int topOpticalSensorPin = 0; // the cell and 4.7K pulldown are connected to analog pin A0 int topOpticalSensorReading; // variable to hold the optical float sensor // MAIN PROGRAM SETUP void setup(void) { Serial.begin(9600); // Initialise serial communications } // MAIN PROGRAM LOOP void loop(void) { topOpticalSensorReading = analogRead(topOpticalSensorPin); // take a reading from the optical sensor pin Serial.print("TOP OPTICAL SENSOR READING = "); // Print string to console Serial.print(topOpticalSensorReading); // the analog reading of the optical sensor if (topOpticalSensorReading < 100) { Serial.println(" - TOUCHING WATER - YES"); } else if (topOpticalSensorReading < 400) { Serial.println(" - TOUCHING WATER - NO"); } else { Serial.println(" - TOUCHING WATER - NO"); } }