⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blinky.c

📁 很实用的单片机例程
💻 C
字号:
/* BLINKY.C - LED Flasher for the Keil MCBx51 Evaluation Board with 80C51 device*/
                  
#include <REG51.H>

// When you have enabled the option Stop Program Execution with Serial
// Interrupt, the Monitor-51 uses the serial interrupt of the UART.
// It is therefore required to reserve the memory locations for the interrupt
// vector.  You can do this by adding one of the following code lines:

// char code reserve [3] _at_ 0x23;   // when using on-chip UART for communication
// char code reserve [3] _at_  0x3;   // when using off-chip UART for communication

void wait (int nms)  {                   /* wait function */
unsigned int i;  
 while(nms--)
 {
  for (i = 0; i < 125; i++);                                   /* only to delay for LED flashes */
  }
}

void main (void)  {
 // unsigned int i;                     /* Delay var */
//  unsigned char j;                    /* LED var */
	 P1 = 0xff;   
  while (1) {                         /* Loop forever */    
      P1 = 0xff;                         /* Output to LED Port */     
       wait (300);                       /* call wait function */    
      P1 = 0x00;                         /* Output to LED Port */    
       wait (300);                       /* call wait function */    
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -