标题:
STM32单片机PCF8591程序
[打印本页]
作者:
A2102179814
时间:
2022-4-28 15:56
标题:
STM32单片机PCF8591程序
#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);
}
}
PCF8591.7z
2022-4-29 20:12 上传
点击文件名下载附件
下载积分: 黑币 -5
225.39 KB, 下载次数: 49, 下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1