这个例程就是用两个数组存放,显示的LED值,然后循环显示。
以下是程序:
/*
* GccApplication10.c
*
* Created: 2014-10-4 17:29:35
* Author: Administrator
*/
#define F_CPU 8000000UL
#include <avr/io.h>
#include <stdint.h>
#include <util/delay.h>
const int8_t Pattern_P0[] =
{
0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0x3e,0xdf
};
const int8_t Pattern_P1[] =
{
0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0x3e,0xdf
};
int main(void)
{
int8_t i;
DDRC = 0xFF;
PORTC = 0xFF;
DDRD = 0xFF;
PORTD = 0xFF;
while(1)
{
for(i=0;i<16;i++)
{
PORTC = Pattern_P0[i];
PORTD = Pattern_P1[i];
_delay_ms(80);
}
}
}
以下是Studio的编译截图:
以下是仿真截图:
|