8x8 LED Dot Matrix 2 Color + Freeduino

Sciguy
Thank you. For instructions. :slight_smile:

595 595 595 Freeduino
PIN 16 <==> PIN 16 <==> PIN 16 ====> digital pin 13
PIN 12 <==> PIN 12 <==> PIN 12 ====> digital pin 8
PIN 11 <==> PIN 11 <==> PIN 11 ====> digital pin 12
pin 14 ======================> digital pin 9
pin 14 =============> digital pin 10
pin 14 ====> digital pin 11

retrolefty
This is my code.

int latchPin = 8;
int clockPin = 12;

int dataPin = 9;
int dataPinRed = 10;
int dataPinGreen = 11;

int powerPin = 13;

byte data;

byte dataArray[22];

int Red = 1;
int Green = 2;
int Orange = 3;

void setup() {

  pinMode(latchPin, OUTPUT);
  pinMode(powerPin,OUTPUT);
  digitalWrite(powerPin,HIGH);
  
  myarray();

}

void loop(){
  
  for(int i = 0 ; i <= 5000 ; i++){
  dotshow(random(1, 9),random(1, 9),random(1, 3));
  delay(1);}
  
  
  
  for(int c = 1 ; c <= 3 ; c++){
  for(int i = 1 ; i <= 8 ; i++){
  rowshow(i,c);
  delay(100);}
  for(int i = 8 ; i >= 1 ; i--){
  rowshow(i,c);
  delay(100);}
  dotshow(0,0,c);
  delay(500);
  }
  
  for(int c = 1 ; c <= 3 ; c++){
  for(int i = 1 ; i <= 8 ; i++){
  colshow(i,c);
  delay(100);}
  for(int i = 8 ; i >= 1 ; i--){
  colshow(i,c);
  delay(100);}
  dotshow(0,0,c);
  delay(500);
  }
  
 
  for(int i = 0 ; i <= 30 ; i++){
  fourshow(random(1, 3),random(1, 3),random(1, 4));
  delay(300);}




}


void dotshow(int myRow,int myCol, int color){

    byte dotRow;
    byte dotColRed;
    byte dotColGreen;
    
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3649][ch3606][ch3623][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621]
    for(int i = 1; i <= 8 ; i++){
    if( myRow == i){dotRow = dataArray[8 - i];}}
    
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3588][ch3629][ch3621][ch3633][ch3617][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621] + [ch3585][ch3635][ch3627][ch3609][ch3604][ch3626][ch3637]
    for(int i = 1; i <= 8 ; i++){
    if(myCol == i){
    if(color == 0){ dotColRed =dataArray[16] ;   dotColGreen =dataArray[16];} 
    if(color == 1){ dotColRed =dataArray[16] ;  dotColGreen =dataArray[16-i];} 
    if(color == 2){ dotColRed =dataArray[16-i] ;  dotColGreen =dataArray[16];} 
    if(color == 3){ dotColRed =dataArray[16-i] ;  dotColGreen =dataArray[16-i];}}}
    
    //[ch3649][ch3626][ch3604][ch3591][ch3607][ch3640][ch3585] Dot
    if(myRow == 0 && myCol == 0){ dotRow = dataArray[16];
    if(color == 1){ dotColRed =dataArray[16] ;  dotColGreen =dataArray[17];} 
    if(color == 2){ dotColRed =dataArray[17] ; dotColGreen =dataArray[16];} 
    if(color == 3){ dotColRed =dataArray[17] ;  dotColGreen =dataArray[17];}}
    
    //[ch3649][ch3626][ch3604][ch3591][ch3612][ch3621]
    digitalWrite(latchPin, 0);
    shiftOut(dotRow,dotColRed,dotColGreen);
    digitalWrite(latchPin, 1);

}

//____________ [ch3649][ch3626][ch3604][ch3591][ch3607][ch3637][ch3656][ch3621][ch3632][ch3649][ch3606][ch3623]

void rowshow(int myRow,int color)
{
    byte dotRow;
    byte dotColRed;
    byte dotColGreen;
    
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3649][ch3606][ch3623][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621]
    for(int i = 1; i <= 8 ; i++){
    if( myRow == i){dotRow = dataArray[8 - i];}}
   
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3626][ch3637]
    if(color == 0){ dotColRed =dataArray[16] ;  dotColGreen =dataArray[16];}
    if(color == 1){ dotColRed =dataArray[16] ;  dotColGreen =dataArray[17];} 
    if(color == 2){ dotColRed =dataArray[17] ;  dotColGreen =dataArray[16];} 
    if(color == 3){ dotColRed =dataArray[17] ;  dotColGreen =dataArray[17];}
  
    digitalWrite(latchPin, 0);
    shiftOut(dotRow,dotColRed,dotColGreen);
    digitalWrite(latchPin, 1);
  
 }
 
 //____________ [ch3649][ch3626][ch3604][ch3591][ch3607][ch3637][ch3656][ch3588][ch3629][ch3621][ch3633][ch3617]
 void colshow(int myCol,int color)
{
   
    byte dotColRed;
    byte dotColGreen;
    
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3588][ch3629][ch3621][ch3633][ch3617][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621] + [ch3585][ch3635][ch3627][ch3609][ch3604][ch3626][ch3637]
    for(int i = 1; i <= 8 ; i++){
    if(myCol == i){
    if(color == 0){ dotColRed =dataArray[16] ;   dotColGreen =dataArray[16];} 
    if(color == 1){ dotColRed =dataArray[16] ;   dotColGreen =dataArray[16-i];} 
    if(color == 2){ dotColRed =dataArray[16-i] ; dotColGreen =dataArray[16];} 
    if(color == 3){ dotColRed =dataArray[16-i] ; dotColGreen =dataArray[16-i];}}}
  
    digitalWrite(latchPin, 0);
    shiftOut(dataArray[16],dotColRed,dotColGreen);
    digitalWrite(latchPin, 1);
  
 }

 //____________ [ch3649][ch3626][ch3604][ch3591] 4x4
 void fourshow(int myRow,int myCol, int color)
{
    byte dotRow;
    byte dotColRed;
    byte dotColGreen;
    
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3649][ch3606][ch3623][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621] [ch3610][ch3609]-[ch3621][ch3656][ch3634][ch3591]
    if( myRow == 2){dotRow = dataArray[18];}
    if( myRow == 1){dotRow = dataArray[19];}
    
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3588][ch3629][ch3621][ch3633][ch3617][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621][ch3588][ch3629][ch3621][ch3633][ch3617] [ch3595][ch3657][ch3634][ch3618]-[ch3586][ch3623][ch3634] + [ch3585][ch3635][ch3627][ch3609][ch3604][ch3626][ch3637]
   
    if(myCol == 1){
    if(color == 0){ dotColRed =dataArray[16] ; dotColGreen =dataArray[16];} 
    if(color == 1){ dotColRed =dataArray[16] ; dotColGreen =dataArray[18];} 
    if(color == 2){ dotColRed =dataArray[18] ; dotColGreen =dataArray[16];} 
    if(color == 3){ dotColRed =dataArray[18] ; dotColGreen =dataArray[18];}}
    
    if(myCol == 2){
    if(color == 0){ dotColRed =dataArray[16] ; dotColGreen =dataArray[16];} 
    if(color == 1){ dotColRed =dataArray[19] ;   dotColGreen =dataArray[16];} 
    if(color == 2){ dotColRed =dataArray[16] ; dotColGreen =dataArray[19];} 
    if(color == 3){ dotColRed =dataArray[19] ; dotColGreen =dataArray[19];}}
  
    digitalWrite(latchPin, 0);
    shiftOut(dotRow,dotColRed,dotColGreen);
    digitalWrite(latchPin, 1);
  
 }



void shiftOut(byte myDataOut,byte myDataOutRed,byte myDataOutGreen) {
  
  int i=0;
 
  
  int pinState;
  int pinStateRed;
  int pinStateGreen;
  
  pinMode(clockPin, OUTPUT);
  
  pinMode(dataPin,OUTPUT);
  pinMode(dataPinRed,OUTPUT);
  pinMode(dataPinGreen,OUTPUT);

  digitalWrite(dataPin, 0);
  digitalWrite(dataPinRed, 0);
  digitalWrite(dataPinGreen, 0);
  
  digitalWrite(clockPin, 0);

  
  for (i=0; i<=7; i++)  {
  digitalWrite(clockPin, 0);
    
    if ( myDataOut  & (1<<i) ) { pinState= 1; } else {pinState = 0;}
    if ( myDataOutRed & (1<<i)) { pinStateRed= 1;} else {pinStateRed= 0;}
    if ( myDataOutGreen & (1<<i) ) { pinStateGreen= 1; } else {pinStateGreen=0;}

    digitalWrite(dataPin, pinState );
    digitalWrite(dataPinRed,  pinStateRed);
    digitalWrite(dataPinGreen, pinStateGreen);
    
    digitalWrite(clockPin, 1);
    
    digitalWrite(dataPin,0);
    digitalWrite(dataPinRed, 0);
    digitalWrite(dataPinGreen, 0);
  
  }
  
  digitalWrite(clockPin, 0);
}

void  myarray(){

  dataArray[0]   = 0x80; //10000000
  dataArray[1]   = 0x40; //01000000
  dataArray[2]   = 0x20; //00100000
  dataArray[3]   = 0x10; //00010000
  dataArray[4]   = 0x08; //00001000
  dataArray[5]   = 0x04; //00000100
  dataArray[6]   = 0x02; //00000010
  dataArray[7]   = 0x01; //00000001
  
  dataArray[8]   = 0x7F; //01111111
  dataArray[9]   = 0xBF; //10111111
  dataArray[10]  = 0xDF; //11011111
  dataArray[11]  = 0xEF; //11101111
  dataArray[12]  = 0xF7; //11110111
  dataArray[13]  = 0xFB; //11111011
  dataArray[14]  = 0xFD; //11111101
  dataArray[15]  = 0xFE; //11111110
  
  dataArray[16]  = 0xFF; //11111111
  dataArray[17]  = 0x00; //00000000
  
  dataArray[18]  = 0xF0; //11110000
  dataArray[19]  = 0x0F; //00001111
  
}

I come from thailand

My English is not good

::slight_smile:

[ch3655]Hello = " Sa Wat Dee"
Nice to meet you all.