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
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
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
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!)
Previous article:Single chip electronic clock program
Next article:STC microcontroller watchdog feeding program
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
Guess you like
- pyEC, an electric bike controller compatible with pyBoard
- Bear Pie Huawei IoT operating system LiteOS bare metal driver transplantation 06-E53_ST1 expansion board driver and use
- I bought 8 apples last week and ate one every day, starting with the small ones. The last one had a rotten hole in it, so...
- node-red simulates LED flashing light control system program
- 2021 ON Semiconductor Avnet RSL10 Bluetooth SoC Development and Design Competition First Post
- Are Decoupling Capacitors Really What You Need?
- 【i.MX6ULL】Driver Development 3——GPIO Register Configuration Principle
- 【Renovation of old things】 Finished product of graffiti desk lamp
- Prototyped a PCB expansion board
- [Practical sharing] Sharing of analog circuit diagrams commonly used by electronic engineers