If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).
In other words, if nothing is connected, the value returned will be random. That's normal. The pin is floating, so it has to return something.
I have an alarm system and I connect the zones response led (wich is 1,3 volt work) parallel to my arduino analog pins.
My code looks like this:
...
int anHeight=50;
radars="";
for (an = 0; an < 6; an++){
if (analogRead(an)>anHeight){
radars+="1|";
}else{
radars+="0|";
}
}
int x=alarm('radars',radars);
Radars string I post to a web server database and I have a monitor web page to visit my alarm status.
Yesterday I get always 0|0|0.... Today just 1|1|1... And i don't know why
for (an = 1; an < 6; an++) {
_timeArray[an]=0;
_intArray[an]=true;
}
You're only setting five of the ten elements of the array "_intArray" to "true" - is that what you intended?
(_timeArray already was all set to zero so you didn't need to do that at all)
but now i don't know how can I measure the 0 volt
I don't understand your question.
Are you saying you have some open switch connected to an analogue input without a pullup or pulldown?
myDuino:
Ok thank you for the adveices, I will coretct the fails, but now i don't know how can I measure the 0 volt (standby state of alarm zone response led)
If you are getting random voltages when the alarm output is 0, add a high value pull down resistor (maybe 50k or 100k) with one end of the resistor connected between the alarm output and the arduino analog input pin, and the other end of the resistor connected to the arduino ground.