Single chip microcomputer controls the flashing of LED lights

Publisher:咖啡狐狸Latest update time:2012-12-01 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
/*51 MCU controlled LED flashing pattern program, pre-store various flashing combinations of LED lights in the table, then use the table lookup to read the data in the table and output it to the P2 port. This method is often used to control neon lights. The original source of this program: 51Hei MCU http://www.51hei.com , the source code is as follows, if you have any questions, please correct me*/
#include
void main(void)
{const unsigned char design[32]={0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F, 0x7F,
0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF, 0xFF,
0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x0,
0xE7,0xDB,0xBD,0x7E,0xFF}; //Define pattern data unsigned int a; //Define variable unsigned char b
for loop ;
//Due to limited memory, pay attention to the use of variable types in C51 programming
do{ //do while type loop
for (b=0; b<32; b++)
{for(a=0; a<30000; a++); //Delay for a period of time
P2 = design; //Read the defined pattern data and write the pattern data to port P2
}
} while(1);
}
void main() //Main function
{ unsigned char OutData=0xfe; //Define output data and initial value
for(;;) //Infinite loop
{
P2=OutData; //Output OutData to port P2 to turn on an LED in port P2
OutData=_crol_(OutData,1); //Shift OutData left circularly to shift the on LED one position to the left
mDelay(100); //Call the delay function and delay for 100 milliseconds
}}
Reference address:Single chip microcomputer controls the flashing of LED lights

Previous article:Program for single-chip microcomputer to control LED lighting with a single button
Next article:51 MCU timer 0 interrupt service routine

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号