新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 用DAC0808實(shí)現(xiàn)數(shù)字調(diào)壓

用DAC0808實(shí)現(xiàn)數(shù)字調(diào)壓

作者: 時(shí)間:2016-11-17 來源:網(wǎng)絡(luò) 收藏
C代碼:

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

本文引用地址:http://m.butianyuan.cn/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);
}
}

仿真電路



關(guān)鍵詞: DAC0808數(shù)字調(diào)

評論


技術(shù)專區(qū)

關(guān)閉