led.c
来自「CCSC 16F877 LED 控制C语言程序。」· C语言 代码 · 共 34 行
C
34 行
///////////////////////////////////////////////////////////////////////////////
// MPLAB IDE V7.11 + CCS C3.18
// LED2 for MCD2-demo
//
// by LW7807@163.com
// 2005/06/16
///////////////////////////////////////////////////////////////////////////////
#include "16F877A.h" // PIC16F877 header file
#use delay(clock=4000000) // for 4Mhz crystal
#fuses XT, NOWDT, NOPROTECT, NOLVP // for debug mode
void main(void)
{
int8 tmp = 0; // tmp var
set_tris_b(0xff); // set PORTB for intput
set_tris_c(0x00); // set PORTC for output
output_c(tmp); // PORTC output 0
while(1){
while(1 == (input_b()&0x01)) // wait put button
{
delay_ms(10);
}
output_c(++ tmp); // output number
while(0 == (input_b() & 0x01)) // wait free button
{
delay_ms(10);
}
}//end while(1)
}//end main()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?