標(biāo)題:
單片機(jī)LED點(diǎn)陣程序看不明白了
[打印本頁(yè)]
作者:
黃油蝴蝶
時(shí)間:
2024-1-27 10:00
標(biāo)題:
單片機(jī)LED點(diǎn)陣程序看不明白了
如圖的4個(gè)8*8拼成的16*16點(diǎn)陣,我想讓這個(gè)點(diǎn)陣的箭頭從左下角向左上角移動(dòng),但不知為什么,最上面一排LED會(huì)跟隨著亮,求解答
#include<reg51.h>
sbit LE1=P3^6;
sbit LE2=P3^7;
typedef unsigned char uint8_t;
typedef unsigned char bool;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long int uint64_t;
uint64_t pattern[]={
0x7f000000,0x3f000000,0x1f000000,0x3f000000,
0x7f000000,0xfb000000,0x71000000,0x20000000
};
void delay(uint16_t n)
{
while(n--);
}
int main (void)
{
char Startpos,Endpos;
char abovesign;
uint8_t loop;
uint8_t times;
uint16_t dat;
while(1)
{
for(abovesign=-1;abovesign<=22;abovesign++)
{
Startpos=0x10-(uint8_t)abovesign;
Endpos=Startpos+7;
for(times=0;times<=50;times++)
{
for(loop=0x00;loop<=0x0f;loop++)
{
if(loop>=Startpos&&loop<=Endpos)
{
dat=(pattern[loop-Startpos]>>abovesign)>>8;
}
else
{
dat=0x0000;
}
P2&=0x00;
P3&=0xf0;
delay(2);
P3|=loop;
P2&=0x00;
LE1=1;
P2|=(uint8_t)(dat);
delay(3);
LE1=0;
delay(2);
P2&=0x00;
LE2=1;
P2|=(uint8_t)(dat>>8);
delay(3);
LE2=0;
delay(2);
}
}
delay(10);
}
}
return 0;
}
復(fù)制代碼
作者:
joyb
時(shí)間:
2024-1-28 08:46
abovesign=-1;時(shí),
(uint8_t)abovesign是多少?
作者:
cedtek
時(shí)間:
2024-1-28 20:46
圖片在哪里?硬件連線圖麻煩補(bǔ)一個(gè)唄
作者:
黃油蝴蝶
時(shí)間:
2024-1-30 12:29
不好意思,忘貼硬件圖了
屏幕截圖 2024-01-27 095458.png
(55.06 KB, 下載次數(shù): 67)
下載附件
2024-1-30 12:27 上傳
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1