Use Proteus to complete a simple marquee

Proteus draws graphics

Open proteus, click p on the left toolbar to enter the search interface, and enter AT89C51 in the search interface to select the first chip for this experiment. Insert picture description here
Then search to get the LED light and connect it to the chip. The specific effect is as follows: the
Insert picture description here
only point that needs attention is the direction of the LED light. The LED is unidirectional. When connecting, change the direction of the LED light as needed.

Keil performs C language programming and converts it into a hex file

Make settings before writing the code so that the compiled C language hex file will be automatically saved after the programming is completed, so that it is convenient for proteus to
Insert picture description here
check the Create HEX File option afterwards, and click OK after completion. Then click project in the menu bar to create the project file name
Insert picture description here
, choose AT89C51 chip in the next prompt page and Insert picture description hereclick OK to complete the creation of the project file, then click file to create the test file, and enter the following code in it. Save it as C language and add it to the project file

#include <reg51.h>                //包含头文件 
#include <intrins.h>     //包含移位库函数头文件
void delay(void)      //延时函数 
{
    
     
 unsigned char i,j; 
 for(i = 0;i < 252;i++) 
  for(j = 0;j < 252;j++); 
}
void main(void) 
{
    
     
  unsigned char i; 
 P2 = 0x01;     //P2口初始化
 while(1) 
 {
    
     
   for(i = 0;i < 7;i++) 
  {
    
     
    P2 = _crol_(P2,1);    //P2端口向左循环移动1位 
   delay();   
  }
  for(i = 0;i < 7;i++) 
  {
    
     
    P2 = _cror_(P2,1);    //P2端口向右循环移动1位 
   delay();   
  } 
 } 
}

Insert picture description here
Insert picture description here
Insert picture description here
At this point, the writing of the code on keil is completed

Experimental result

Import the hex file of the code written in keil into the chip on proteus, and the
Insert picture description herefinal effect picture is shown below

Insert picture description here
Due to limited technology, it is not possible to display the effect as a GIF picture, roughly because the lights will light up one by one and light up in cycles from left to right

This article refers to https://blog.csdn.net/tian_maer/article/details/71435894

Guess you like

Origin blog.csdn.net/java_creater/article/details/108958752