May I recommend the attached schematic as a solution to your limited pins?
With the attached schematic, pot command can be used to read different values of each button hit. Even the combination of button hits can provide different readings.
The key points are as follows.
1. All resistors must be +/-1% or better tolerance.
2. This application may not be suitable in the environments where ambient temperature changes sharply.
3. “Select Case“command needs to be used to divert the resistor readings.
Example:
Pot porta.0, 255,BtnRead
Select Case BtnRead
Case is >20 and is <25 ‘Actual BtnRead=22, The safe reading range is wider then the resistor tolerance.
Goto Menu1
Case is >26 and is <31 'Actual BtnRead=28
Goto Menu2
.
..
…
….
End select
4. Resistor values need to be determined experimentally. If the values are too close then the range of one button may intersect with the range of another button.
--------------------------------------------------
Bookmarks