Button control water light program

Publisher:中原读书客Latest update time:2015-07-09 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Recently, many junior students have come to ask me how to make a running light and how to write a program. Now I will tell you all about
      it here. Many times, I don’t have time to let you go for nothing, O(∩_∩)O~. First of all, let’s talk about the single-chip microcomputer. The single-chip microcomputer is a new concept for you, and you may not have heard of it before. What I want to say is that it is not an integrated circuit in the traditional sense, which can only work according to specific welding. It is a chip similar to a computer CPU. For a normal single-chip microcomputer, as long as you provide a suitable working power supply (4V is about 5.5V), reset circuit, and oscillator circuit, it can work. All input and output ports (starting with P) can be flexibly configured. You can write programs according to the hardware circuit you welded, or you can weld the hardware circuit according to the program you wrote. So there is no need to be rigid. I wrote it the day before yesterday when I had nothing to do, and it worked after simulation. The source code is posted below for beginners to refer to. Experts please don't laugh at me. We all started with the running light program (*^__^*) Hehe...
      I don't know who borrowed my 51 development board. I haven't used the 51 microcontroller for a long time, so don't come to me for downloading programs. I also posted the compiled code below. If you have the same hardware as me and don't know how to write programs, just copy the compiled code below, create a new text document (.txt) on the computer and name it arbitrarily, paste the copied code in Notepad, then rename it, change ".txt" to ".hex", save it, and then download it to the microcontroller through the downloader and you can use it.
      If you don't know how to do it, go to http://www.51hei.com  to look at the tutorial. The following is for reference only, please do not blindly imitate        
/********************************************************************************************************************************************************************************************************************
/ #include #define uint unsigned int #define uchar unsigned char
sbit
key1
=P2^0; //Key
1 sbit key2 =P2^ 1; //Key 2 sbit key3 =P2^2; //Key 3 uchar flag1=0,flag2=0,flag3=0; void delay_ms (
uint z) {      uint i,j;      for(i=0;i>i);                             delay_ms(100);                             key_scan(); //key scan    























































                            if(flag2||flag3){flag1=0;break;} //If other keys are pressed, respond to other keys
                   }
             }
             if(flag2) //One key is pressed?                   
             {
                    for(i=0;i<8;i++) //Light up from right to left, one at a time  
                   {
                            P0=~(0x01<                             delay_ms(100);
                            key_scan();
                            if(flag1||flag3){flag2=0;break;}
                   }
             }
              if(flag3)
             {
                   O_to_E(); //Even and odd flash alternatelykey_scan
                   ();
                   if(flag1||flag2)flag3=0;
              }
        }
}
/***********************************************************************************************************************
Compiled file
Note: Copy the following code (be careful not to include this sentence, and be careful not to change the format)
:09015700010800010900010A0081
:040123007F0A7E00D1 ; 012796
:
0A00F400F4F5807F647E00120127FE : 1000FE0020A00912012320A00375080120A10912D6 :10010E00012320A10375090120A20912012320A2B7 :05011E0003750A012237 : 10008F001200FE1200FEE5086021E4F97480A80159 :10009F00088002C31 3D8FC1200F4E5097004E50AC6 : 1000AF006005E4F508800409B908E1E509601FE47B :1000BF00F97401A801088002C333D8FC1200F4E5DB :1000CF00087004E50A6003E4F50909B908E3E50AD5 :1000DF0060B11201471200FEE5087004E50960A344 :0500EF00E4F50A809E0B :03000000020003F8 : 0C0 00300787FE4F6D8FD75810A02004AFF :10000F0002008FE493A3F8E493A34003F68001F278 :10001F0008DFF48029E493A3F85407240CC8C333F2 :10002F00C4540F4420C8834004F456800146F6DFC1 :10003F00E4800B0102040810204080900157E47EF9 :10004F00019360BCA3FF543F30E509541FFEE493B6 :10005F00A360010ECF54C025E060A840B8E493A37D :10006F00FAE493A3F8E493A3C8C582C8CAC583CAA8 :10007F00F0A3C8C582C8CAC583CADFE9DEE780BE60 :01016000009E :00000001FF End (Be careful not to include this sentence and the ※ above, and be careful not to change the format!)

























Reference address:Button control water light program

Previous article:Single chip electronic clock program
Next article:STC microcontroller watchdog feeding program

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号