您的位置 首页 解答

用DAC0808完成数字调压

C代码:#includereg52.h>#defineuintunsignedint#defineucharunsignedcharsbitK1=P3^0;sbitK2=P3^1;sbitK3.

C代码:

#include
#define uint unsigned int
#define uchar unsigned char

sbit K1 = P3^0;
sbit K2 = P3^1;
sbit K3 = P3^2;
sbit K4 = P3^3;
sbit K5 = P3^4;
sbit K6 = P3^5;
sbit K7 = P3^6;
sbit K8 = P3^7;

void DelayMS(uint ms)
{
uchar i;
while(ms–)
{
for(i=0;i<120;i++);
}
}

void main()
{
P2 = 0x00;
while(1)
{
if(K1 == 0) P2 = 0;
if(K2 == 0) P2 = 35;
if(K3 == 0) P2 = 70;
if(K4 == 0) P2 = 105;
if(K5 == 0) P2 = 140;
if(K6 == 0) P2 = 175;
if(K7 == 0) P2 = 210;
if(K8 == 0) P2 = 255;
DelayMS(2);
}
}

仿真电路

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/jieda/268454.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部