新闻中心

EEPW首页>嵌入式系统>设计应用> 用DAC0808实现数字调压

用DAC0808实现数字调压

作者: 时间:2016-11-17 来源:网络 收藏
C代码:

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

本文引用地址://m.amcfsurvey.com/article/201611/315535.htm

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);
}
}

仿真电路



关键词:DAC0808数字调

评论


技术专区

关闭