|
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "lcd.h"
#include "usart.h"
# include "pcf8591.h"
# include "myiic.h"
# include "24cxx.h"
u8 adcData[4];
int ad;
//void adshow()
//{
// adcData[0] = PCF8591_ADC_Input(0x90 ,0x40); //电位器
// ad= (int)((adcData[0]/25.5)*100); //将浮点数扩大100倍,并转化为int型 255/10=25.5
//
// LCD_ShowNum(50,100,ad%1000/100,1,16);
// LCD_ShowNum(62,100,ad%100/10,2,16);
// LCD_ShowNum(80,100,ad%10,2,16);
//
//}
int main(void)
{
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
uart_init(115200); //串口初始化为115200
LED_Init(); //LED端口初始化
LCD_Init();
PCF8591_Init();
POINT_COLOR=BLACK;
while(1)
{
// adshow();
adcData[0] = PCF8591_ADC_Input(0x90 ,0x40); //电位器
adcData[1] = PCF8591_ADC_Input(0x90 ,0x41); //光敏
LCD_ShowNum(100,100,adcData[0],3,24);
LCD_ShowNum(100,200,adcData[1],3,24);
}
}
|
评分
-
查看全部评分
|