# Using digital pins for reading analog value

When I connect the pressure sensor to an analog pin of WEMOS D1 MINI board I'm getting values between 300 when the sensor is not pressed, and 700 when it is pressed. But I wanted to connect 10 pressure sensors so I connected it to digital pins because I need only 2 states 0 and 1. I thought that, if the value is less than 512 digitalRead method returns 0, and 1 if the value is more than 512. But now I getting spam on serial port because values are changing all the time. When pressure sensor is not active I'm getting only 000000000 and that's ok, but when I press the sensor I'm getting 01011101.

Am I right that when I connect the sensor to digital I can get values 0 and 1, or should I use an analog multiplexer to connect everything through analog pins?

• I don't know what logic family those pins will be but the high/low thresholds will be defined, and are often not half the supply voltage. For reference: learn.sparkfun.com/tutorials/logic-levels/…. One approach could be to have a comparator circuit comparing the reading to an appropriate reference voltage which will generate a nice clean 0 or 1 that is read by the digital pin. – jramsay42 May 20 '20 at 7:29