f_8_19a_ledtoggle_a.c

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

C
28
字号
#include "config.h"#include "delay.h"// this code illustrates a WRONG way to toggle// an LED on or off after a switch press and release.// LED will actually be ON while switch is// held down, and OFF when switch the is released.// Does NOT toggle on press and release.// Also, no switch debouncing delay is included. void main(void){  TRISB = 0xEF;		// set RB4 as output    RB4 = 0;		// turn RB4 off  while(1) {     if (!RB6) {      // switch pressed, turn on LED      RB4 = 1;    }    if (RB6) {      // switch pressed, turn off LED      RB4 = 0;    }  }}

⌨️ 快捷键说明

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