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

📄 f_8_18b_ledsw_b.c

📁 * Use 10 MHz crystal frequency. * Use Timer0 for ten millisecond looptime. * Blink "Alive" LED e
💻 C
字号:
#include "config.h"#include "serial.c"#include "serio.c"#include "delay.h"// this code illustrates one RIGHT way to read a switch// for press and release.// Modified from book example so that loop is// exited after 'i' reaches 5, and message// is printed. So loop is not exited until // switch is pressed and relased 5 times.//  void main(void){  int i;  TRISB = 0xEF;		// set RB4 as output    RB4 = 0;		// turn RB4 off  serial_init(95,1);   // 19200 in HSPLL mode, crystal = 7.3728 MHz   pcrlf();printf ("Press switch when ready!");pcrlf();  i = 0;  // illustrates wrong way to read a switch for presses  while(i < 5) {  // exit loop if i >= 5    // wait for press    while(RB6);  //loop (1)    DelayMs(30); //debounce    // wait for release    while (!RB6); //loop (2)    DelayMs(30);   //debounce    i++;  }  printf("loop exited, i value is: %d\n",i); pcrlf();  while(1);  // loop forever}

⌨️ 快捷键说明

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