A classic Microcontroller program for controlling LEDs

Source: Internet
Author: User

This was originally a question I did in my junior year. It was an out-of-class exercise. In the single-chip microcomputer course, an experiment is to control the digital display of a clock. The program logic is very simple and can be expressed by the following pseudo code.
While (true)
{
Accumulate ms time and carry;
If (ScanKeys (& code ))
ProcessKey (code); // process the key
Display (); // refresh the Digital Display
}

The above logic is based on memory, and is actually written in 8051 assembly language, control 6 Led7-segment digital tubes. Output the display code to a port or a peripheral to control the digital display. The hour, minute, and second are stored in the storage unit. You can press a specific key to adjust the value of the hour, minute, and second of the clock.

This part of the code already exists in the book. The instructor's extra-curricular question is like this. He said that when he tried to adjust the time, the corresponding data bit blinks. And screen saver functions. In the end, I was the only professional who made this program (of course, because few people tried to do this). I made dynamic Screen Saver effects (inspired by the flash of the neon lights) beyond the expectation of the teacher. I remember that I quickly drew a detailed flowchart and quickly wrote the main function code. Then, two weeks later, we could have a chance to get on the machine. After a long, anxious and excited wait. It is not until I enter all the written code on my computer. After simple debugging, the code runs successfully and the expected results are displayed.

I drew a clean and clear flowchart on the draft and introduced a state variable in the internal register. Through this variable, I recorded the status of the current program, which is blinking, screensaver, it is still displayed normally. Then, different Display control codes are output in the Display function based on the corresponding status and specific time.

After many years, I checked my own Led controls and suddenly came up with the idea of re-implementing the Single-Chip Microcomputer Program in winform. I thought it was not difficult, but the status was cumbersome, it still took some time to debug.

Effect:

Source code: (vs2005)
Http://files.cnblogs.com/hoodlum1980/LedTest_02 (vs8).rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.