【51蛋骗鸡按键控制流水速度快慢数码管显示;按键切换流水方向3则】2022-3-7
缘由按键控制流水速度快慢,数码管显示-职场和发展-CSDN问答
#include "REG52.h"
#include<intrins.h>
sbit K1 = P3^0;
sbit K2 = P3^1;
sbit K3 = P3^2;
unsigned char code SmZiFu[]={63,6,91,79,102,109,125,7,127,111,119,124,57,94,121,113,118,128,255,64,0};//0-9A-FH.消隐-全显
unsigned char Js=0,miao=0,fen=0,shi=0,y=6,t=23,ls=0;//中断计时
void ZhongDuanSheZhi(/*中断设置*/)
{TH0+=0X4c;/*定时器赋初值,定时50ms触发中断,自动补偿方式*/TL0+=0X00; TMOD=0X01;TR0=1;ET0=1; //开启定时器EA=1; //全局中断开关
}
void smxs(unsigned char mz,unsigned char w,unsigned char d)
{unsigned char Xd=0;P0=255;P0=(255-(d==1?SmZiFu[mz]:(SmZiFu[mz]|0x80)));//小数点闪烁P2=w;while(++Xd);
}
void main()
{unsigned char Xd=0,xz=255,cs=0,ss=20,s1=0,s2=0,s3=2,s4=3;unsigned int wei=47474;ZhongDuanSheZhi();P1=1;while(1){smxs(ss/10,1,1);smxs(ss%10,2,1);if(K1==0&&++Xd==0){ss=20;while(!K1);Js=0;};if(K2==0&&++Xd==0){ss-=4;while(!K2);Js=0;};if(K3==0&&++Xd==0){ss+=4;while(!K3);Js=0;};if(Js==ss){P1=_cror_(P1,1);Js=0;}}
}
void ZhongDuan() interrupt 1
{++Js;TH0=0X4C;//0X4C 50 0XDC 10TL0=0X00;
}
缘由学51单片机程序设计-微软技术-CSDN问答
void main()
{unsigned char Xd=0,xz=255,cs=0,ss=20,s1=0,s2=0,s3=2,s4=3;unsigned int wei=47474;ZhongDuanSheZhi();P1=1;while(1){if(Js==ss){if(K3==0)P1=_cror_(P1,1);else P1=_crol_(P1,1);Js=0;}}
}
缘由用开关实现与,或,异或-嵌入式-CSDN问答
void main()
{unsigned char Xd=0,xz=255,cs=0,ss=20,s1=0,s2=0,s3=2,s4=3;unsigned int wei=47474;ZhongDuanSheZhi();P1=~cs;while(1){if(K1==0&&++Xd==0){++cs;while(!K1);};if(cs>3)cs=0;P1=~cs;}
}