8个LED灯花样流水c程序代码

2022-05-20 03:26:15   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《8个LED灯花样流水c程序代码》,欢迎阅读!
花样,流水,代码,程序,LED
#include

#define uchar unsigned char #define uint unsigned int void delay(uint t)//延时函数 {

uint x,y;

for(x=t;x>0;x--)

for(y=110;y>0;y--); }

void main()//主函数 {

uchar temp,i; while(1) {

temp=0x01; //8盏灯单个亮向左移 for(i=0;i<8;i++) {

P2=~temp; delay(50); temp<<=1; }

temp=0x80;

for(i=0;i<8;i++)//8盏灯单个亮反向右移 {

P2=~temp; delay(50); temp>>=1; }

temp=0xfe;

for(i=0;i<8;i++)//8盏灯逐个向右亮 {

P2=temp; delay(50); temp<<=1; }

temp=0xfe;

for(i=0;i<8;i++)//8盏灯逐个灭向右 {

P2=~temp; delay(50); temp<<=1; }

temp=0x7f;

for(i=0;i<8;i++)//8盏灯逐个亮向左


{

P2=temp; delay(50); temp>>=1; }

temp=0x7f;

for(i=0;i<8;i++)//8盏灯逐个灭向右 {

P2=~temp; delay(50); temp>>=1; }

delay(100); P2=0x55;//隔一个亮 delay(100);

P2=0xaa;//隔一个亮 delay(100); P2=0x00;//全亮 delay(100); P2=0xff;//全灭 } }


本文来源:https://www.wddqxz.cn/4405452a91c69ec3d5bbfd0a79563c1ec5dad7b9.html

相关推荐