led.lst

来自「《PIC单片机C语言开发入门》所有章节源程序」· LST 代码 · 共 35 行

LST
35
字号
     1: #include        <pic.h>
     2: 
     3: /*
     4:  *      Demo program
     5:  *
     6:  *      Flashes LEDs on Port B, responds to switch press
     7:  *      on RA1. Usable on PICDEM board.
     8:  *
     9:  *      Copyright (C)1997 HI-TECH Software.
    10:  *      Freely distributable.
    11:  */
    12: 
    13: #define PORTBIT(adr, bit)       ((unsigned)(&adr)*8+(bit))
    14: 
    15: static bit      button @        PORTBIT(PORTC, 1);
    16: 
    17: 
    18: main(void)
    19: {
    20:         unsigned char   i, j;
    21: 
    22:         TRISB = 0;              /* all bits output */
    23:         j = 0;
    24:         for(;;) {
    25:                 PORTB = 0x00;           /* turn all on */
    26:                 for(i = 100 ; --i ;)
    27:                         continue;
    28:                 PORTB = ~j;             /* output value of j */
    29:                 for(i = 100 ; --i ;)
    30:                         continue;
    31:                 if(button == 0)         /* if switch pressed, increment */
    32:                         j++;
    33:         }
    34: }

⌨️ 快捷键说明

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