Common algorithms for microcontroller data collection

Publisher:cloudsousou6Latest update time:2015-10-08 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
u8TPAD_Init()

{
 u16 buf[10];
 u16 temp;
 u8 j,i;
 for(i=0;i<10;i++)//10 samples

   
  buf[i]=TPAD_Get_Val();
  delay_ms(10);     
       
 for(i=0;i<9;i++)//Ascending order

{
  for(j=i+1;j<10;j++)
  {
   if(buf[i]>buf[j])//

{
    temp=buf[i];
    buf[i]=buf[j];
    buf[j]=temp;
   }
  }
 }
 temp=0;
 for(i=2;i<8;i++)temp+=buf[i] ;//È¡ ÖмäµÄ8¸öÊý¾Ý½øÐÐƽ¾ù
 tpad_default_val=temp/6;
 return 0;                    
}

Reference address:Common algorithms for microcontroller data collection

Previous article:The most commonly used Long variable to BCD code
Next article:Long press and short press of independent buttons

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号