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

📄 led.c

📁 PIC单片机C语言开发入门(源程序).书中的源程序看对大家是否有用
💻 C
字号:
#include	<pic.h>

/*
 *	Demo program
 *
 *	Flashes LEDs on Port B, responds to switch press
 *	on RA1. Usable on PICDEM board.
 *
 *	Copyright (C)1997 HI-TECH Software.
 *	Freely distributable.
 */

#define	PORTBIT(adr, bit)	((unsigned)(&adr)*8+(bit))

static bit	button @	PORTBIT(PORTC, 1);


main(void)
{
	unsigned char	i, j;

	TRISB = 0;		/* all bits output */
	j = 0;
	for(;;) {
		PORTB = 0x00;		/* turn all on */
		for(i = 100 ; --i ;)
			continue;
		PORTB = ~j;		/* output value of j */
		for(i = 100 ; --i ;)
			continue;
		if(button == 0)		/* if switch pressed, increment */
			j++;
	}
}

⌨️ 快捷键说明

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