新手試試 --- Arduino RGB Dot Matrix Blink w/o PWM

係網上係搵到E塊RGB Dot Matri既link,
http://item.taobao.com/auction/i ... ?cm_cat=0&pm1=1
http://www.sparkfun.com/datasheets/Components/YSM-2388CRGBC.pdf

RGB Dot Matrix
RGBMatrix.jpg
2009-8-27 19:25


手上只係有74HC373,於是攞黎用。正好個RGB Dot Matrix係共陰,所以都啱用。
不過因為parallel輸入輸出,D線會十分之多。74HC373既datasheet就係E度搵到。
http://www.alldatasheet.com/data ... SAS/HD74HC373P.html

就用4粒74HC373搞個簡單既RGB原色閃燈試下。4粒74HC373就分別推C,R,G,B。並且係RGB輸出串接限流電阻。
為左減少接線,隻output control腳就接左地。同埋加番過Blink開始指示LED,用Arduino pin 1推。

Arduino pin 2-9就係信號輸出,而pin 13-10就係CRGB選擇。

就係好似E張線路圖咁砌。

RGB Dot Matrix Blink Schematic Diagram
[local=315,250ˇ]1[/local]
RGBMatrix__v1.jpg

TOP

寫個code試下。
  1. /*
  2.   Single 8X8 RGB Matrix Common Cathode - Simple Blink W/O PWM

  3.   Layout:
  4.    
  5.    Drive: HD74HC373P x4

  6.     gnd = OC Red, Green, Blue, Common
  7.    pin2 = 1D
  8.    pin3 = 2D
  9.    pin4 = 3D
  10.    pin5 = 4D
  11.    pin6 = 5D
  12.    pin7 = 6D
  13.    pin8 = 7D
  14.    pin9 = 8D
  15.   pin10 = En G Blue
  16.   pin11 = En G Green
  17.   pin12 = En G Red
  18.   pin13 = En G Common
  19.   
  20.    pin1 = Blink Loop Start LED
  21.   
  22. */


  23.   void setup()   {               
  24.   // initialize the digital pin as an output:
  25.   for (int i=1; i <= 13; i++)
  26.   {
  27.   pinMode(i, OUTPUT);
  28.   }
  29.   // initialize the digital pin to switch off the RGB Matrix:
  30.   for (int i=13; i <= 10; i--)
  31.   {
  32.   digitalWrite(i, LOW);
  33.   delay(10);
  34.   }
  35.   for (int i=2; i <=9; i++)
  36.   {
  37.   digitalWrite(i, HIGH);
  38.   }
  39.   digitalWrite(13,HIGH);  
  40.   delay(10);
  41.   digitalWrite(13, LOW);
  42.   delay(10);
  43.   for (int i=2; i <=9; i++)
  44.   {
  45.   digitalWrite(i, LOW);
  46.   }
  47.   for (int i=12; i <= 10; i--)
  48.   {
  49.   delay(20);  
  50.   digitalWrite(i, HIGH);
  51.   delay(20);
  52.   digitalWrite(i, LOW);
  53.   delay(50);
  54.   }
  55.   for (int i=1; i <=10; i++)
  56.   {
  57.   digitalWrite(1, HIGH);
  58.   delay(100);
  59.   digitalWrite(1, LOW);
  60.   delay(300);
  61.   }
  62.   delay(1000);
  63. }

  64. void loop()                     
  65. {
  66. for (int zp=2; zp <=9; zp++)
  67. {
  68.   for (int i=2; i <=9; i++)
  69.   {
  70.   digitalWrite(i, HIGH);
  71.   }  
  72.   digitalWrite(zp, LOW);
  73.   digitalWrite(13,HIGH);  
  74.   delay(10);
  75.   digitalWrite(13, LOW);
  76.   delay(10);
  77.    
  78.   for (int i=10; i <=12; i++)
  79.   {
  80.     for (int j=2; j <=9; j++)
  81.     {
  82.         for (int y=2; y <=9; y++)
  83.         {
  84.         digitalWrite(y, LOW);
  85.         }      
  86.     digitalWrite(j, HIGH);
  87.     delay(10);   
  88.     digitalWrite(i,HIGH);  
  89.     delay(10);
  90.     digitalWrite(i, LOW);
  91.     delay(10);
  92.     digitalWrite(j, LOW);
  93.     delay(10);
  94.     digitalWrite(i,HIGH);  
  95.     delay(10);
  96.     digitalWrite(i, LOW);
  97.     delay(10);
  98.       }   
  99.     }  
  100.   }
  101.   for (int i=1; i <=3; i++)
  102.   {
  103.   digitalWrite(1, HIGH);
  104.   delay(100);
  105.   digitalWrite(1, LOW);
  106.   delay(100);
  107.   }
  108. }
複製代碼
ps:打錯顏色。

[ 本帖最後由 zonebaby 於 2009-8-27 23:28 編輯 ]

TOP

E個Code都係放在examples入面....

RGB Dot Matrix Blink Location

當Compile同upload成功後,再等一陣,個Blink開始指示LED就會出反應,
並開始一個一個閃落去,然後再重覆,....。

RGB Dot Matrix Blink Success
RGBMatrix Success.jpg
2009-8-27 19:27


RGB Dot Matrix Blink 試機成功.......

ps:打錯動作開始說明改番。

[ 本帖最後由 zonebaby 於 2009-8-27 23:05 編輯 ]

TOP

後記1:
試過正常,改落PCB,冇咁亂,順手練下soldering。

RGB Dot Matrix PCB Front
RGBMatrix_PCB_Front.jpg
2009-8-29 14:55


RGB Dot Matrix PCB Rear
RGBMatrix_PCB_Rear.jpg
2009-8-29 14:55


RGB Dot Matrix RED
RGBMatrix_Red.jpg
2009-8-29 14:55


RGB Dot Matrix Blue
RGBMatrix_Blue.jpg
2009-8-29 14:55


[ 本帖最後由 zonebaby 於 2009-8-29 14:55 編輯 ]

TOP

後記2:
順手改左個code,寫個簡單既單色圖案blink試下。

code
  1. /*
  2.   1 x  8X8 RGB Matrix Common Cathode - Simple Blink W/O PWM

  3.   Layout:
  4.    
  5.    Drive: HD74HC373P x4

  6.     gnd = OC Red, Green, Blue, Common
  7.    pin2 = 1D
  8.    pin3 = 2D
  9.    pin4 = 3D
  10.    pin5 = 4D
  11.    pin6 = 5D
  12.    pin7 = 6D
  13.    pin8 = 7D
  14.    pin9 = 8D
  15.   pin10 = En G Blue
  16.   pin11 = En G Green
  17.   pin12 = En G Red
  18.   pin13 = En G Common
  19.   
  20.    pin1 = Blink Loop Start LED
  21.   
  22. */
  23.   
  24.   const static byte Pattern[20] = {
  25.     B01111110,B00001100,B10110111,B10011110,B11001101,
  26.     B11011011,B11111010,B00001111,B11111110,B11011110,
  27.     B01111110,B00001100,B10110111,B10011110,B11001101,
  28.     B11011011,B11111010,B00001111,B11111110,B11011110
  29.   };

  30.   long randColor;
  31.   long randPattern;
  32.   int colorpin;
  33.   void setup()   {   

  34.   Serial.begin(9600);
  35.   randomSeed(analogRead(0));
  36.   
  37.   // initialize the digital pin as an output:
  38.   pinMode(1, OUTPUT);
  39.   DDRB = DDRB | B00111111;
  40.   DDRD = DDRD | B11111100;

  41.   // initialize the digital pin to switch off the RGB Matrix:

  42.   PORTB &= B11000011;
  43.   delay(1);
  44.   PORTD &= B00000011;
  45.   PORTB &= B11000000;
  46.   delay(1);
  47.   PORTB |= B00111100;  //switch on CRGB input
  48.   delay(1);
  49.   PORTB &= B11000011;  //switch off CRGB input
  50.   delay(10);
  51.   //test RGB
  52.   for (colorpin=12; colorpin >=10; colorpin--)
  53.   {
  54.     PORTD |= B11111100;
  55.     PORTB |= B00000011;
  56.     digitalWrite(colorpin,HIGH);  
  57.     delay(800);
  58.     PORTD &= B00000011;
  59.     PORTB &= B11111100;
  60.     digitalWrite(colorpin, LOW);
  61.     delay(200);
  62.   }
  63.   // switch off the display
  64.   PORTD |= B11111100;
  65.   PORTB |= B00000011;
  66.   digitalWrite(13,HIGH);
  67.   digitalWrite(13,LOW);   
  68.   
  69.   // link Loop Start LED
  70.   for (int i=1; i <=5; i++)
  71.   {
  72.     digitalWrite(1, HIGH);
  73.     delay(100);
  74.     digitalWrite(1, LOW);
  75.     delay(100);
  76.   }
  77. }

  78. void loop()                     
  79. {
  80. randPattern = random(1,9);
  81. randColor = random(10,13);
  82.   for (int i=1; i <=10; i++)
  83.   {  
  84.   for (int zp=2; zp <=9; zp++)
  85.   {
  86.     //row selection
  87.     PORTD |= B11111100;
  88.     PORTB |= B00000011;
  89.     digitalWrite(zp, LOW);
  90.     digitalWrite(13, HIGH);
  91.     digitalWrite(13, LOW);
  92.     PORTD &= B00000011;
  93.     PORTB &= B11111100;
  94.     //row pattern
  95.     PORTD |= (B11111100 & Pattern[randPattern+zp]);
  96.     PORTB |= (B00000011 & Pattern[randPattern+zp]);
  97.     //set color
  98.     digitalWrite(randColor, HIGH);
  99.     delay(1);
  100.     PORTD &= B00000011;
  101.     PORTB &= B11111100;
  102.     digitalWrite(randColor, LOW);
  103.   }
  104.   }
  105. }
複製代碼

[ 本帖最後由 zonebaby 於 2009-8-30 13:27 編輯 ]

TOP

後記3:
加番D單色圖案試機圖。

RGB Dot Matrix Full R,G,B
RGBMatrix_AllRed.jpg
2009-8-30 13:27
RGBMatrix_AllGreen.jpg
2009-8-30 13:27
RGBMatrix_AllBlue.jpg
2009-8-30 13:27


RGB Dot Matrix Pattern R,G,B
RGBMatrix_PatternRed.jpg
2009-8-30 13:27
RGBMatrix_PatternGreen.jpg
2009-8-30 13:27
RGBMatrix_PatternBlue.jpg
2009-8-30 13:27

TOP