极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9733|回复: 1

Arduino 和8x8 dot matrix 问题

[复制链接]
发表于 2013-9-8 17:57:05 | 显示全部楼层 |阅读模式

好不容易可以显示到一个A字。但看会去自己的programming, array很奇怪。其实我只是要做比如两个input(Active low),当第一个input1 trigger时,会显示A。如果是input2 trigger 时会显示B。大概是这样。但写到这边,不会了。 我用两个74HC595。一个col,一个给Row。




  1. int latchPin = 5;
  2. int clockPin = 6;
  3. int dataPin = 4;
  4. int i,j;

  5. int row;
  6. int rowlatchPin = 10;
  7. int rowclockPin = 9;
  8. int rowdataPin = 8;



  9. byte colMatrix[][1] = {

  10. {0x00},
  11. {0x3f},
  12. {0x44},
  13. {0x44},
  14. {0x44},
  15. {0x44},
  16. {0x3f},
  17. {0x00}

  18. };

  19. void setup()
  20. {
  21.   pinMode(latchPin, OUTPUT);
  22.   pinMode(dataPin, OUTPUT);  
  23.   pinMode(clockPin, OUTPUT);
  24.   
  25.    pinMode(rowlatchPin, OUTPUT);
  26.   pinMode(rowdataPin, OUTPUT);  
  27.   pinMode(rowclockPin, OUTPUT);
  28. }

  29. void loop()
  30. {
  31.   /*leds = 0;
  32.   updateShiftRegister();
  33.   delay(500);
  34.   for (int i = 0; i < 8; i++)
  35.   {
  36.     bitSet(leds, i);
  37.     updateShiftRegister();
  38.     delay(500);
  39.   }*/
  40.   
  41.    //use a nested for loop to initialize all the pins

  42.    for(row = 0; row <8; row++)
  43.    {
  44.     int rowbit= 1<<row;
  45.     digitalWrite(rowlatchPin, LOW);
  46.     shiftOut(rowdataPin, rowclockPin, MSBFIRST,rowbit);
  47.    
  48.     digitalWrite(latchPin, LOW);
  49.    
  50.     for(int j =7; j>=0; j--)
  51.     {
  52.     shiftOut(dataPin, clockPin, MSBFIRST, colMatrix[row][j]);
  53.     }
  54.      digitalWrite(latchPin, HIGH);
  55.      digitalWrite(rowlatchPin, HIGH);
  56.      delayMicroseconds(500);  
  57.    }   
  58. }
复制代码

回复

使用道具 举报

 楼主| 发表于 2013-9-8 17:58:25 | 显示全部楼层
希望你们帮帮忙。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-8 11:26 , Processed in 0.035186 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表