注:
PCF8591 是8位AD-DA芯片 转化数据0—5 对应 0–255
通信协议IIC
模拟量输出值和电压的联系: 输出电压=(参阅电压-基点电位)/255
//以下是源码如果在网页上显现格局紊乱能够从这儿下载:http://www.51hei.com/f/8591c.rar
//12MHZ晶振
#include
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define uint unsigned int
#include “I%&&&&&%.h”//i2c库函数
code uchar seg[]={0x28,0x7e,0xa2,0x62,0x74,0x61,0x21,0x7a,0x20,0x60}; //数码管码表
code uchar tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; //数码管位选
code uchar tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; //数码管位选
sbit bz=P3^3; //喇叭位
uchar outdata;//模拟量输出值
sbit k1=P1^2 ; //模拟量输出者添加
sbit k2=P1^1; //模拟量输出者削减
sbit k2=P1^1; //模拟量输出者削减
void delay(uint k) //延时子函数
{
while(k–);
}
{
while(k–);
}
void key1() //模拟输出值添加
{
if(k1==0)
{
delay(1000);
if(k1==0)
outdata++;
}
}
{
if(k1==0)
{
delay(1000);
if(k1==0)
outdata++;
}
}
void key2() //模拟输出值削减
{
if(k2==0)
{
delay(1000);
if(k2==0)
outdata–;
}
}
{
if(k2==0)
{
delay(1000);
if(k2==0)
outdata–;
}
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/jieda/318384.html