本帖最後由 bear20591 於 2015-1-7 11:57 編輯
如題請問我想要做16*24(還是24*16)的點矩陣跑馬燈
現在字型抓不到
只會持續亮第一行
掃瞄端是74154*2
輸出端是74373*2
上圖為實際接線圖(麥克風是之後要加的功能,但現在跑馬燈就出不來了...)
程式如下:
int delaymsecond=200;
#define repeat
30
int decoder_74154_1[]={17,18,19,20,21};
int decoder_74154_2[]={22,24,26,28,30};
int buffer_74373_1[]={36,38,40,42,44,46,48,50,52};
int buffer_74373_2[]={37,39,41,43,45,47,49,51,53};
unsigned char code[8][2][16]={
{ {0x00,0x01,0x01,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x01,0x01,0x00}, //"三" 上半部
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40} }, //"三" 下半部
{ {0x00,0x00,0x10,0x08,0x84,0xd5,0x85,0xff,0xff,0x85,0xd5,0x84,0x08,0x10,0x00,0x00}, //"電" 上半部
{0x00,0x00,0x00,0x00,0x1f,0x16,0x16,0xff,0xff,0x96,0x56,0x1f,0x00,0x00,0x00,0x00} }, //"電" 下半部
{ {0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xc2,0xe2,0x32,0x1a,0x0e,0x06,0x00,0x00,0x00}, //"子" 上半部
{0x00,0x01,0x01,0x01,0x01,0x09,0x11,0x3f,0x7f,0x01,0x01,0x01,0x01,0x01,0x01,0x00} }, //"子" 下半部
{ {0x00,0x00,0x00,0xfc,0x24,0x24,0x24,0xfc,0xfc,0x24,0x24,0x24,0xfc,0x00,0x00,0x00}, //"甲" 上半部
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00} }, //"甲" 下半部
{ {0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xfe,0x00,0x00,0x00}, //"3" 上半部
{0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7f,0x00,0x00,0x00} }, //"3" 下半部
{ {0x00,0x00,0x00,0xfe,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0xfe,0x00,0x00,0x00}, //"0" 上半部
{0x00,0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7f,0x00,0x00,0x00} }, //"0" 下半部
{ {0x00,0x00,0x00,0xfe,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xfe,0x00,0x00,0x00}, //"4" 上半部
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00,0x00} }, //"4" 下半部
{ {0x00,0x00,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xfe,0x00,0x00,0x00}, //"2" 上半部
{0x00,0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00} } }; //"2" 下半部
void setup() {
pinMode(17,OUTPUT); //74154_1 解碼輸出腳
pinMode(18,OUTPUT);
pinMode(19,OUTPUT);
pinMode(20,OUTPUT);
pinMode(21,OUTPUT);//G2 控制腳
pinMode(22,OUTPUT); //74154_2 解碼輸出腳
pinMode(24,OUTPUT);
pinMode(26,OUTPUT);
pinMode(28,OUTPUT);
pinMode(30,OUTPUT);//G2 控制腳
pinMode(36,OUTPUT);//74373_1_解碼輸出腳
pinMode(38,OUTPUT);
pinMode(40,OUTPUT);
pinMode(42,OUTPUT);
pinMode(44,OUTPUT);
pinMode(46,OUTPUT);
pinMode(48,OUTPUT);
pinMode(50,OUTPUT);
pinMode(52,OUTPUT);//Enable G_1 控制腳
pinMode(37,OUTPUT);//74373_2_解碼輸出腳
pinMode(39,OUTPUT);
pinMode(41,OUTPUT);
pinMode(43,OUTPUT);
pinMode(45,OUTPUT);
pinMode(47,OUTPUT);
pinMode(49,OUTPUT);
pinMode(51,OUTPUT);
pinMode(53,OUTPUT);//Enable G_2 控制腳
}
void loop() {
while (1) // 無窮盡迴圈
{
for (int i=0;i<8;i++) // 八個字
for (int j=0;j<repeat;j++) // 重複掃瞄repeat次
{
for (int scan=0;scan<16;scan++) // 掃瞄迴圈
{
buffer_74373_1=i; // 關閉LED(防殘影)
buffer_74373_2=i;
decoder_74154_1[scan]=scan; // 輸出掃瞄信號
delay(1); // 延遲1ms
} // 完成掃瞄一個字型
} // 完成重複repeat次(j迴圈)
}
}
我知道很多問題...
拜託各位大大幫助了(其實是專題做不出來... |