Realizing the 8-LED Flowing Light Effect in a Single Chip Microcomputer

Publisher:知识阁楼Latest update time:2020-04-14 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Left shift function _crol_(x,y) and array implementation

#include

#include

#define uint unsigned int

#define uchar unsigned char

uchar temp;/*The variable type and the assigned value should be consistent. Port P1 is an 8-bit register, so uchar*/

void delay(uint);

void main()

{   

temp=0XFE;

P1=temp;

while(1)

{

temp=_crol_(temp,1); //circular shift left

delay(300);

P1=temp;

}

}


void delay(uint z)

{

uint x,y;

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

for(y=z;y>0;y--);

}

```


// Array implementation


```

#include

#include

#define uint unsigned int

#define uchar unsigned char

uchar i;

uchar table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};


void delay(uint z)

{

uint x,y;

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

for(y=z;y>0;y--);

}


void main()

{   


while(1)

{

for(i=0;i<8;i++)

{

P1=table[i];

delay(300);

}


}


Reference address:Realizing the 8-LED Flowing Light Effect in a Single Chip Microcomputer

Previous article:51 single chip microcomputer static digital tube display
Next article:"Beginner's C51 Self-study Notes" - Flowing Light Implementation (Bit Operation)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号