当前位置: 首页 > article >正文

2021-07-20 51单片机流水灯递增点亮

缘由这个是stc15f2k60s2单片机的流水灯 哪里错了嘛 为啥跑不出来(゚O゚)_嵌入式-CSDN问答

void main()
{
	unsigned char Xd=0,ss=1,cs=0;
	unsigned int ys=0;
	while(1)
	{
		if(++ys==0)
        {
            Xd+=ss;
            P0=Xd;
            ss*=2;
            if(ss==0)
            {
                ss=1;
                Xd=0;
            }
        }
	}
}

十六进制算法实现

void main()
{
	unsigned char wei=0,Xd=0x00,Sw=0x01;
	unsigned int Ys=47474,Lx=0;
	P0=P1=P2=P3=0;
	while(1)
	{
		if(!--Ys)
		{
			Xd+=Sw;
			P0=Xd;
			Sw+=Sw;
			if(!Sw)
			{
				Sw=0x01;
				Xd=0x00;
			}
		}
	}
}

 有清零的效果算法

void main()
{
	unsigned char wei=0,Xd=0x00,Sw=0x01;
	unsigned int Ys=47474,Lx=0,ls=0x01;
	P0=P1=P2=P3=0;
	while(1)
	{
		if(!--Ys)
		{
			Xd+=ls;
			P0=Xd;
			ls+=ls;
			if(ls>255*2)
			{
				ls=0x01;
				Xd=0x00;
				while(++Lx)P0=Xd;
			}
		}
	}
}


http://www.kler.cn/a/226474.html

相关文章:

  • golang网络编程day4
  • 《苍穹外卖》知识梳理P4-异常处理
  • delete、truncate和drop区别
  • 深入理解指针(4)
  • 泰克示波器(TBS2000系列)触发功能使用讲解——边沿触发
  • Jenkins自动化打包
  • RISC-V指令格式
  • Java中indexOf() 方法详解
  • 【Uni-App】运行微信小程序时报错routeDone with a webviewId 2 that is not the current page
  • 全面认识DOS系统
  • 机器学习复习(4)——CNN算法
  • 格式化内存卡后,如何找回丢失的监控视频?
  • 大数据(Bigdata)数据集
  • Kotlin快速入门系列6
  • 2024年混合云:趋势和预测
  • 带着问题读源码——Spring MVC是怎么找到接口实现类的?
  • Linux升级openssh的解决方案
  • 【乳腺肿瘤诊断分类及预测】基于Elman神经网络
  • Loadbalancer如何优雅分担服务负荷
  • Redis内存设置