Page 179 - MDP2020-2
P. 179

················································································  명장양성프로젝트  【MDP】  과제발표회  자료집  Ⅱ    |  173



                        Serial.print("TDS  Value:");
                        Serial.print(tdsValue,0);
                        Serial.println("ppm");
                  }
            }

            int  getMedianNum(int  bArray[],  int  iFilterLen)
            {
                        int  bTab[iFilterLen];
                        for  (byte  i  =  0;  i<iFilterLen;  i++)
                        bTab[i]  =  bArray[i];

                        int  i,  j,  bTemp;
                        for  (j  =  0;  j  <  iFilterLen  -  1;  j++)
                        {
                        for  (i  =  0;  i  <  iFilterLen  -  j  -  1;  i++)
                                {

                            if  (bTab[i]  >  bTab[i  +  1])
                                    {
                            bTemp  =  bTab[i];
                                    bTab[i]  =  bTab[i  +  1];
                            bTab[i  +  1]  =  bTemp;
                              }

                        }
                        }
                        if  ((iFilterLen  &  1)  >  0)
                    bTemp  =  bTab[(iFilterLen  -  1)  /  2];

                        else
                    bTemp  =  (bTab[iFilterLen  /  2]  +  bTab[iFilterLen  /  2  -  1])  /  2;
                        return  bTemp;
            }
   174   175   176   177   178   179   180   181   182   183   184