|
- #include "stm32f10x.h"
- #include "delay.h"
- #include "fdc2214.h"
- #include "oled.h"
- #include "sys.h"
- #include "myiic.h"
- #include "stdio.h"
- #include "KG.h"
- int average(void)
- {
- int i,sum=0,Max_s_0=0;
- for(i=1;i<=10;i++)
- {
- FDC2214_GetData();
- Data_processing();
- if(Max_s_0<=s_0) Max_s_0=s_0;
- sum+=s_0;
- }
- return (sum-Max_s_0)/9;
- }
- int main (void)
- {
- int a;
- delay_init();
- FDC2214_IIC_Init();
- OLED_Init();
- OLED_Display_On();
- IIC_Init();
- FDC2214_Init();
- KG_Init();
- OLED_Display_On();
- // OLED_ShowNum(0,0,9,1,16);
- // OLED_Refresh_Gram();
- while(1)
- {
- a=average()/10;
- a=s_0/10;
- OLED_Show3FNum(0,0,a,6,0,12);
- OLED_Refresh_Gram();
- KG0=1;
- KG1=0;
- if(525<=a&&a<=530)
- {
- KG0=0;
- KG1=0;
- delay_ms(5000);
- }
- OLED_Refresh_Gram();
-
- if(505<=a&&a<=510)
- {
- KG0=0;
- KG1=0;
- delay_ms(5000);
- }
- OLED_Refresh_Gram();
-
- if(485<=a&&a<=490)
- {
- KG0=0;
- KG1=0;
- delay_ms(5000);
- }
- OLED_Refresh_Gram();
-
- if(a<470)
- break;
- }
-
- while(1)
- {
- a=average()/10;
- OLED_Show3FNum(0,0,a,6,0,12);
- OLED_Refresh_Gram();
- KG0=0;
- KG1=1;
- if(a>550) break;
- }
- }
-
复制代码
利用的是fdc2214传感器,以供参考。
|
-
-
main.zip
612 Bytes, 下载次数: 12, 下载积分: 黑币 -5
-
-
oled.zip
3.96 KB, 下载次数: 9, 下载积分: 黑币 -5
-
-
KG.zip
549 Bytes, 下载次数: 10, 下载积分: 黑币 -5
-
-
KG (2).zip
289 Bytes, 下载次数: 8, 下载积分: 黑币 -5
|