5

I am thinking about building a circuit that is literally going to take 11 of the 14 digital pins of an UNO to communicate with an SD card and an external EEPROM chip (EEPROM programmer).

Using 4 shift registers and the SD card, I will have 1 digital pin left. Well, I'm also reserving pins 0/1 for serial communication.

Anyway, I need to read some external buttons and I have the 6 analog pins that I haven't touched.

I will only need about 4-5 push buttons in my design so they should fit nicely on A0+.

So, my question is, will I run into any issues doing this? Or, are the analog inputs better left for true analog reading?

Thanks.

cbmeeks
  • 247
  • 2
  • 10

2 Answers2

8

The Analog pins are essentially identical in functionality to digital pins when used as digital I/O.

If desired you could "be clever" and use an analog input in analog mode to read multiple keys using one pin. eg using 10k, 22k, 39k, 82k, 150k in series with 5 buttons from V+ to pin and a say 4k7 to ground would result in 5 voltages which were easily distinguished using an analog read. This is a very very old technique indeed and allows far more than 5 keys on one input pin. THere are limitations which can be discussed if required.

R1 ... R5 correspond to buttons 1...5

Vout = V+ x Rb / (Rb + Rbutton)

Example only

Rb = 39k
R1 = 10k
R2 = 22k
R3 = 39k
R4 = 82k
R5 = 150k

Gives

  • The % of V+ in column 2 when a button is pressed.

  • The voltage in column 3 with V+ = 5V

Delta-V is the difference between that key and the one below - very ample clearance.

enter image description here

enter image description here

Russell McMahon
  • 2,421
  • 11
  • 14
2

If you have no use for analog pins there is no problem. A5/A6 are used for I²C (on the Uno).

Milliways
  • 1,655
  • 2
  • 18
  • 29