Questions about Programming a Servo Motor [Solved]

I told you I don't have your sensors: I used a potentiometer to mimic your sensors to just give a varying value for the analogRead().

sayHovis:
... admittedly without your sensors but using a potentiometer on the basis that an analog signal from a pot is the same as one from an analog sensor, and just comparing to some threshold.

I certainly was not going to order some sensors that I will never use again, just to test your code.


Let's step back and check if any of your sensors work. Forget the servo stuff for a moment: do you have a simple sketch that reads one of your sensors and gives a different value between it being wet and dry?

Just this in loop() should do the trick:

void loop()
{
Serial.println(analogRead(A0));
delay(100);
}

What values do you get as you move a sensor in and out of a glass of water like this guy who going by your image in #22/23 has the same sensor.

If all you're doing is checking the presence or absence of water rather than the depth then perhaps the threshold needs to be set very low? Totally dry, out of the water, would be 0 maybe, but just touching the surface might be 1 or 2, I don't know.

You need to guarantee the sensors are working and that you know what threshold value you actually need.

Where did this 450 come from?

const int sensorWetThreshold = 450;

Since an analogRead() goes from 0-1023 that would presumably be the sensor about half-way in water? Did you test that value or just chose it randomly?


So do everyone a favour (not least yourself :wink: ), forget the code you have so far, and just print out the values from the sensor as described.