旋转 led 时钟,用单片机做,我给他发邮箱

2024-12-19 09:27:30
推荐回答(4个)
回答1:

我有一个qq274108610

#include

#define W_U 64
#define W_D 32

sbit DAT=P1^0;
sbit CLK=P1^1;
sbit RCK=P1^2;

sbit LED_R=P1^6;
sbit LED_L=P1^7;

sbit KEY1=P3^4;
sbit KEY2=P3^5;

sbit DSEN=P3^2;

int n=0;

unsigned char code tab2[]={

/*------------------------------------------------------------------------------
源文件 / 文字 : 星光灿烂
宽×高(像素): 64×32
字模格式/大小 : 单色点阵液晶字模,纵向取模,字节正序/256字节
数据转换日期 : 2006-10-29 21:17:15
------------------------------------------------------------------------------*/
0x00,0x00,0x44,0x7F,0x55,0x55,0x55,0x57,0x55,0x55,0x7D,0x01,0x00,0x00,0x00,0x02,
0x02,0x12,0x0A,0x03,0x42,0x7E,0x03,0x0A,0x32,0x02,0x02,0x00,0x00,0x0F,0x00,0x7F,
0x04,0x08,0x0F,0x00,0x00,0x7F,0x00,0x00,0x1F,0x00,0x00,0x0F,0x00,0x7F,0x04,0x04,
0x08,0x78,0x08,0x08,0x38,0x68,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x48,0x88,0x08,0x28,0x28,0x28,0xF8,0x28,0x28,0x28,0x08,0x08,0x00,0x00,0x08,
0x08,0x10,0x30,0xC0,0x00,0x00,0xF8,0x08,0x08,0x08,0x10,0x00,0x00,0x08,0x30,0xC0,
0x40,0x20,0xF8,0x08,0x10,0xF0,0x10,0x10,0xF8,0x00,0x00,0x08,0x30,0xC0,0x40,0x20,
0x90,0x90,0x90,0x90,0x90,0x90,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

unsigned int prictur=0;

void delay(unsigned int i)
{
unsigned int j,k;
for(i;i>0;i--)
for(j=8;j>0;j--)
for(k=20;k>0;k--);
}
void init_port()
{
P1M0=0x00;
P1M1=0x00;

}

void display()
{
unsigned long add=0;
unsigned char num;
unsigned int i;
add=n+prictur*256;

num=tab2[add];
for(i=0;i<8;i++)
{
CLK=0;
DAT=!(0x80&num);
CLK=1;
num<<=1;
}

num=tab2[add+W_U];
for(i=0;i<8;i++)
{
CLK=0;
DAT=!(0x80&num);
CLK=1;
num<<=1;
}

num=tab2[add+2*W_U];
for(i=0;i<8;i++)
{
CLK=0;
DAT=!(0x80&num);
CLK=1;
num<<=1;
}

num=tab2[add+3*W_U];
for(i=0;i<8;i++)
{
CLK=0;
DAT=!(0x80&num);
CLK=1;
num<<=1;
}

RCK=0;
RCK=1;

}

void display_CLR()
{
unsigned int i;
for(i=0;i<32;i++)
{
CLK=0;
DAT=1;
CLK=1;
}

RCK=0;
RCK=1;
}

void LED(unsigned int n)
{
unsigned int i;
for(i=32-n;i>0;i--)
{
CLK=0;
DAT=1;
CLK=1;
}
for(i=n;i>0;i--)
{
CLK=0;
DAT=0;
CLK=1;
}
RCK=0;
RCK=1;
delay(250);
for(i=0;i<32;i++)
{
CLK=0;
DAT=1;
CLK=1;
RCK=0;
RCK=1;
delay(200);
}
}

void main()
{
unsigned int w;
init_port();

n=0;

LED_R=0;
LED_L=1;

while(1)
{
LED_L=!LED_L;
LED_R=!LED_R;

if(KEY1==0)
{
while(!KEY1);
prictur++;
LED(prictur+1);
delay(50);
}

if(KEY2==0)
{
while(!KEY1);
prictur=0;
LED(prictur+1);
delay(50);
}

if(DSEN==0)
{
delay(200);

n=0;
for(w=0;w {

display();
n++;
delay(2);
}

display_CLR();
delay(20);

}

}
}

回答2:

我的qq865038962@qq.com 谢了

回答3:

445022363@qq.com

回答4:

794164997@qq.com,非常感谢啊。