2

My goal is to reduce pins being used for micro-controllers with limited pins, or projects requiring a few different digital input values.

How I intend to do so is by using ADC pins to gather four specific different values through resistors with analogRead, which would otherwise need 2 pins (!A+!B, !A+B, A+!B, and A+B).

value = analogRead(adcPin1) >> 8;

This would give, if properly wired, 4 possible results like some sort of "Quartary bit", as analogRead yields a 10-bit response.

So my questions are the following:

  • Can analogRead be sufficiently reliable to tell the difference between four possible values?
  • What would the wiring/casing/etc. need to look like to prevent any errors?

Thanks!

3
  • 4
    I don't know how reliable it is, but it seems to be a quite commonly used technique. Sep 13, 2020 at 8:56
  • Thank you Edgar that's exactly what I was looking for! Thank you I don't know why I missed on the research :/
    – B7th
    Sep 13, 2020 at 9:26
  • 1
    There are 5-button-pads (sainsmart.com/products/…) available using this technique. It assumes you press only one of the buttons at a time. Just an info, no advertising, no recommendation :) Sep 13, 2020 at 21:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.