i need some details for a better understanding. I’m using pin A4 for a simple fluid switch, so values should be 0 and 1.
First I’ve declared the following:
setup (){
…
pinMode(A4, INPUT_PULLUP);
…
}
and for reading: status = digitalRead(A4);
This worked for some time, but now it stoped and I don’t know why.
I switched to analogRead(A4) and evaluate the response with if(analogRead(A4)<100) {WV=0;} else {WV=1;}
Where is my misunderstanding? Is it possible, that this was changed with the firmware? Switched from 0.6.0 to 0.7.0
digitalRead(A4) should still work as it always did, unless you either activated some other funtion on that pin (e.g. SPI.begin()) or have blown the pin by supplying a too high or negative voltage to it.
You must have had it connected to your switch at some point. Is the other side of the fluid switch connected to GND (the same one as the Photon's)? How long is the wire going to the switch?
@MikeM, a cable that long makes a great antenna for noise and static charge. The internal pull-up is quite weak at 40K ohms. IF the input has not been damaged, I suggest removing the INPUT_PULLUP configuration and using an external 4.7K pull-up coupled with a 0.1uF capacitor (to GND) to reduce noise on the input. Are you debouncing the input?