1. Open the Keil Software
2. Create text1
3. input the program (*** see Appendix 1)
4. Save it as a. c file
5. Create a project
6. Select Atmel-> AT89C51.
7. Right-click source group 1 of the new project and choose add file to Group 1.
8. Right-click the new project name> Option> output> and select create a. HEX file.
9. Compile to obtain the. HEX file;
1. Open protues
2. Draw a picture as follows:
3. Double-click the single-chip microcomputer. In the displayed dialog box, add the generated. HEX file to the program file.
4. debug-> exrcute
* ** Appendix 1
# Include <reg51.h> // the pre-processing file defines the names of special registers. For example, the P1 port is defined as P1.
Void main (void)
{
// Define pattern data
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 };
Unsigned int A; // defines the variable used for Loop
Unsigned char B; // pay attention to the use of variable types due to limited memory in C51 programming.
// Use the smallest byte type as much as possible, which is very useful in large programs
Do {
For (B = 0; B <32; B ++)
{
For (A = 0; A <30000; A ++); // delay for a period of time
P1 = design [B]; // read the defined pattern data and write it to the P1 port.
}
} While (1 );
}