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

📄 led.c

📁 AVR单片机ATMEGA48控制LED灯的C程序
💻 C
字号:
#include <iom48v.h>
#include <macros.h>

/* This seems to produce the right amount of delay for the LED to be
 * seen
 */
void Delay()
	{
	unsigned char a, b;

	for (a = 1; a; a++)
		for (b = 1; b; b++)
			;
	}

void LED_On(int i)
	{
	PORTB = ~BIT(i);	/* low output to turn LED on */
	Delay();
	}

void main()
	{
	int i;
	DDRB = 0x97;	/* output */
	PORTB = 0xFF;	/* all off */

	while (1)
		{
		/* forward march */
		for (i = 0; i < 2; i++)
			LED_On(i);
			i++;
		/* backward march */
		}
	}

⌨️ 快捷键说明

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