现象:用沾水的纸巾已经擦过土壤传感器的表面了
ADC单通道的配置,里面有各种注释,这里就不多废话了
主函数:
#include "stm32f10x.h"
#include "oled.h"
#include "ADC.h"
uint16_t ADValue=0,V=0;
int main()
{
OLED_Init();
MADC_Init();
OLED_ShowString(1,1,"ADValue:");
OLED_ShowString(3,1,"V:");
while(1)
{
ADValue=ADC_GetValue();
V=ADValue/4095.0*3.3*100;
OLED_ShowNum(1,9,ADValue,4);
OLED_ShowNum(3,3,V/100,1);
OLED_ShowString(3,4,".");
OLED_ShowNum(3,5,V%100,2);
}
}
ADC.c
#include "ADC.h"
#include "Delay.h"
void MADC_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;