f_8_5_ledflash.c

来自「* Use 10 MHz crystal frequency. * Use 」· C语言 代码 · 共 36 行

C
36
字号
#include "config.h"

// a subroutine that implements a delay via loops 
// Note that the compile option used will alter this delay! 
// Always use -O compile option 

void a_delay(void){
  unsigned int i,k;
  // change count values to alter delay 
  for (k=1800; --k;) {
    for(i = 200 ; --i ;);
  }
}

// just flash LED on port RB1  
// use this to test if PIC board is alive  
void main(void)
{

  TRISB1 = 0;		// set RB1 as output  
  RB1 = 0;		// turn RB1 off

  while(1) {  // note infinite loop, all PIC programs should
             //	be an infinite loop of some kind. Why? If the
             // loop exited, what would the PIC do?  

    a_delay();  // a subroutine that implements a delay via loops  
    RB1 = 1;	// turn on RB1  
    a_delay();
    RB1 = 0;	// turn off RB1  
  }
}



⌨️ 快捷键说明

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