#include <string.h>
#include <stdio.h>
#define F_CPU 7372800 /*
单片机主频为7.3728MHz,用于延时子程序 */
#include <u
til/delay.h>
#include <avr/io.h>
#include <avr/iom128.h>
//***********************************************************************
// 定义变量区
//***********************************************************************
#define uchar unsigned char
#define uint unsigned int
#define hang PORTE
#define data PORTE.0
#define yiwei PORTE.1
#define reset PORTE.2
#define shuchu PORTE.3
#define dir DDRE
#define delay_us(x) _delay_us(x) //AVR GCC延时函数 x(us)
#define delay_ms(x) _delay_ms(x) //AVR GCC延时函数 x(ms)
uchar shuzi[]={0x66,0x3f};
uchar table[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07};
void xianshi(uchar byte)
{
uint i;
for(i=0;i<8;i++)
{
data=byte&1<<i;
yiwei=0;
yiwei=1;
}
shuchu=0;
shuchu=1;
}
void main()
{
uint j;
dir=0xff;
while(1)
{
for(j=0;j<8;j++)
{
hang=table[j];
xianshi(shuzi[0]);
delay_us(1000);
}
}
}
错误
一周热门 更多>