Multiple switches on single analog pin code

Hi,
When I was looking for some code to check multiple switches I couldn’t find one. Heres the one I’m using.
Using a simple voltage divider you can connect a lot of switches to one analog pin of Arduino.
Here is a code, which will read the value, check which switch is pressed, check if the switch is being held and is able to do a default if the readings are out of chart.

Note: cas[3] is runout in ms (when the sketch goes to hold). LCDsw and PANsw are two groups of switches connected to analog input
TOUCH is just true / false (I’m using NE555 as a touch/proximity sensor)
DisSWread[ic] contains an array of approximate values of reading for every switch

The code isn’t perfect, but is working 100% and I have no problems with it whatsoever. The run time with AD read and evaulation is around 10ms (100cycles/s)

Hope it’ll be useful to someone

void checkSW()
  { 
    int ADTouch1, ADTouch2, ADdisplay1, ADdisplay2, ADdisplay, ADpanel1, ADpanel2, ADpanel, il, ih;
    char ic, rozdilAD, absrozdil;
    
    lastPANsw0 = PANsw0;
    lastLCDsw0 = LCDsw0;
    
    ADTouch1 = analogRead (A0);
    
    ADdisplay1 = analogRead(A3);
    ADdisplay2 = analogRead(A3);
        
    rozdilAD = ADdisplay1 - ADdisplay2; 
    absrozdil = abs(rozdilAD);
    
    if (absrozdil < 5) {ADdisplay = ADdisplay1, ADdisplayOLD = ADdisplay1;} else ADdisplay = ADdisplayOLD;
    
    ADpanel1 = analogRead(A2);
    ADpanel2 = analogRead(A2);
    
    rozdilAD = ADpanel1 - ADpanel2; 
    absrozdil = abs(rozdilAD);
    
    if (absrozdil < 5) {ADpanel = ADpanel1; ADpanelOLD = ADpanel1;} else ADpanel = ADpanelOLD;
    
    if (ADTouch1 > 1000) TOUCH = true; else TOUCH = false;
    
    if (ADdisplay < 5) {LCDsw0 = 0;}    
    else
    if (ADdisplay > 5)
      { for (ic = 0; ic < 12; ic++) 
                {il = DisSWread[ic] - 10;
                 ih = DisSWread[ic] + 10;
                 
                   if (ADdisplay > il && ADdisplay < ih) LCDsw0 = ic + 1;
                }
                
      } 
      
     if (ADpanel < 5) {PANsw0 = 0;}  
     else
     if (ADpanel > 5)
      { for (ic = 0; ic < 11; ic++) 
                {il = PanSWread[ic] - 10;
                 ih = PanSWread[ic] + 10;
                 
                   if (ADpanel > il && ADpanel < ih) PANsw0 = ic + 1;
                }
      }
      
      if (LCDsw0 != lastLCDsw0) {LCDsw = LCDsw0; timesw1 = millis(); LcdHold = false;}
         else if (LCDsw0 == lastLCDsw0 && (millis() - timesw1) < cas[3]) {LCDsw = 0; LcdHold = false;}
            else if (LCDsw0 == lastLCDsw0 && (millis() - timesw1) > cas[3]) {LCDsw = LCDsw0; LcdHold = true;}
            
      if (PANsw0 != lastPANsw0) {PANsw = PANsw0; timesw2 = millis(); PanHold = false;}
         else if (PANsw0 == lastPANsw0 && (millis() - timesw2) < cas[3]) {PANsw = 0; PanHold = false;}
            else if (PANsw0 == lastPANsw0 && (millis() - timesw2) > cas[3]) {PANsw = PANsw0; PanHold = true;}
          
}