基于单片机压力自动检测仿真设计-毕设课设
【资源下载】下载地址如下1534:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl
#include <reg51.h>
#include <intrins.h>
//ADC0832 引脚
sbit ADCS=P2^0;
sbit ADDI=P3^7;
sbit ADDO=P3^7;
sbit ADCLK=P3^6;
unsigned char dispbitcode[8]={0xF7,0xFB,0xFD,0xFE,0xEF,0xDF,0xBF,0x7F}; //位扫描
unsigned char dispcode[11]={0xC0,0xF9,0xA4,0xbB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xFF};
//段选码 共阳极
unsigned char dispbuf[4];
unsigned int temp;
unsigned char getdata;
void delay_1ms(void)
{
unsigned char x,y;
x=3;
while(x--)
{y=40;
while(y--);
}
}
void display(void)
{char k;
for(k=0;k<4;k++)
{
P1=~dispbitcode[k];
P0=~dispcode[dispbuf[k]];
if(k==1)
P0=P0+0x80;
delay_1ms();
}
}
unsigned int ADC0832(unsigned char channel) //AD转换,返回结果
{unsigned char i=0;
unsigned char j;
unsigned int dat=0;
unsigned char ndat=0;
if(channel==0) channel=2;
if(channel==1) channel=3;
ADDI=1;