Hi All,
I'm looking to replace a bunch of pushbuttons on 8 bits of a port by simply using a resistor divider into 1 pin (ADC input).
This free's up a load of pins for other uses.
My drawing shows what i plan to do, but are other people using a better approach?
In my drawing, assuming NONE of the pushbuttons are pressed, then R1 will hold the ADC to the highest amount of the resistor ladder.
I will map a lookup ( or Select..Case) table so that this HIGH value is ignored or considered a 'home' position when no buttons are pressed.
Pressing any the other 4 buttons will obviously create different voltages levels going into the ADC pin.
I've used Select..Case in a similar fashion before, where i setup some 'zones' of a pot to keep it clear of the adjacent 'zone' for stable readings.
So, if the 4 buttons pressed presented readings into the ADC of say 47, 103, 151, 218, i would setup some 'zones' to become:
47 = Range of 40 to 60
103 = Range of 80 to 120
151 = Range of 140 to 160
218 = Range of 190 to 210
The zones will ensure any slight changes in resistors, or pushbutton pressure/conductivity will always give a precise result in the Select..Case table.
Am i on the right track? or should the resistor ladder be improved or done completely differently?
I'm looking to replace a bunch of pushbuttons on 8 bits of a port by simply using a resistor divider into 1 pin (ADC input).
This free's up a load of pins for other uses.
My drawing shows what i plan to do, but are other people using a better approach?
In my drawing, assuming NONE of the pushbuttons are pressed, then R1 will hold the ADC to the highest amount of the resistor ladder.
I will map a lookup ( or Select..Case) table so that this HIGH value is ignored or considered a 'home' position when no buttons are pressed.
Pressing any the other 4 buttons will obviously create different voltages levels going into the ADC pin.
I've used Select..Case in a similar fashion before, where i setup some 'zones' of a pot to keep it clear of the adjacent 'zone' for stable readings.
So, if the 4 buttons pressed presented readings into the ADC of say 47, 103, 151, 218, i would setup some 'zones' to become:
47 = Range of 40 to 60
103 = Range of 80 to 120
151 = Range of 140 to 160
218 = Range of 190 to 210
The zones will ensure any slight changes in resistors, or pushbutton pressure/conductivity will always give a precise result in the Select..Case table.
Am i on the right track? or should the resistor ladder be improved or done completely differently?