📄 main.c
字号:
#include "595.H"
#include <stdio.h>
#include <reg52.h>
#include <intrins.h>
#include <string.h>
#define MID_LIMT 100
#define HIGH_LIMT 350
#define Z_PORT 3
sbit wdg = P1^0;
/****************************************************************************/
void Delay100ms(unsigned char x)
{
unsigned char i,j;
while(x-- != 0)
{wdg =!wdg;
for (j = 0;j < 114; j++)for (i = 0;i < 88; i++){_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
_nop_() ;_nop_() ;_nop_() ;};
}
}
/***********************/
main()
{
unsigned char i,ms[10];
unsigned int y,x;
// dog=!dog;
IP=0x04;
TR0=1;
IT0=0;
EX0=0;
IT1=1;
EX1=0; //外部中断1开放
ET0=1;
ES=0 ; //串口中断打开
//init_com();
EA=0;
//i=0;
//SendStr_MAX7219("1234");
//flash_led();
// Delay100ms(10);
while(1)
{
wdg =!wdg;
for(i=0;i<3;i++) //求平均值
{ x=x+read1543(8);
}
x=x/3;
if(x>=Z_PORT)
{ x=x-Z_PORT;
sprintf(ms," %03d",x);
SendStr_MAX7219(ms);
} //is +
else
{ x=Z_PORT-x;
sprintf(ms,"-%03d",x);
SendStr_MAX7219(ms);
}//-
Delay100ms(1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -