2021-07-03 51单片机1.高低4位交替8次,2.从0到255,3.1+2+3+4...

2024-01-01 06:36:27

缘由求老哥帮做一下单片机题。_嵌入式-CSDN问答

#include "REG52.h"
bit k=1;
void main()
{
	unsigned char Xd=0,ss=15,cs=0;
	unsigned int ys=64000;
	while(1)
	{
		P1=ss;
		if(++ys==0&&cs<8)
        {
            k=~k;
            ++cs;
            ss=(k?15:240);
            ys=64000;
        }
	}
}
#include "REG52.h"
bit k=1;
void main()
{
	unsigned char Xd=0,ss=0,cs=0;
	unsigned int ys=64000;
	while(1)
	{
		P1=ss;
		if(++ys==0)
        {
            ++ss;
            ys=64000;
        }
	}
}
#include "REG52.h"
bit k=1;
void main()
{
	unsigned char Xd=0,ss=1,cs=0;
	unsigned int ys=64000;
	while(1)
	{
		P1=ss;
		if(++ys==0)
        {
            ss+=cs++;
            ys=64000;
        }
	}
}

文章来源:https://blog.csdn.net/xianfajushi/article/details/118443066
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。