Results 1 to 5 of 5

Thread: 3x3 LED Matrix

  1. #1
    Wii U Section Moderator
    Computer Engineer
    MrOwnership's Avatar

    Badge

    Join Date
    Jun 2011
    Location
    Maryland
    Posts
    1,435
    Points
    2,862
         User Info     Contact     Gamer ID
    Join Date
    Jun 2011
    Location
    Maryland
    Posts
    1,435
    Points
    2,862
    Gamer IDs

    Steam ID: MrOwnership Wii Code: MrOwnership

    Default 3x3 LED Matrix

    Here is another little project I have been working on the past few days. It is a simple 3x3 LED matrix with a demo video, schematic, and code. I am working on a 10x10 LED matrix and will post that when I finish it.



    Schematic


    Code
    A little ugly with all the switch statements, but those will be gone as soon as I figure out how to get 3D arrays working on an arduino, or switch to my pi.
    Code:
    int cathode[] = {0,1,2};
    int anode[] = {5,4,3};
    
    int one[][3] =   {{1,1,1}, {1,0,1}, {1,1,1}};
    int two[][3] =   {{0,1,1}, {1,1,1}, {1,1,0}};
    int three[][3] = {{0,1,1}, {1,0,1}, {1,1,0}};
    int four[][3] =  {{0,1,0}, {1,1,1}, {0,1,0}};
    int five[][3] =  {{0,1,0}, {1,0,1}, {0,1,0}};
    int six[][3] =   {{0,1,0}, {0,1,0}, {0,1,0}};
    //int* numbers[6][3][3] = {*one, *two, *three, *four, *five, *six};
    
    int spiral1[][3] =   {{1,1,1}, {1,1,1}, {1,1,1}};
    int spiral2[][3] =   {{1,1,1}, {1,1,1}, {0,1,1}};
    int spiral3[][3] =   {{1,1,1}, {0,1,1}, {0,1,1}};
    int spiral4[][3] =   {{0,1,1}, {0,1,1}, {0,1,1}};
    int spiral5[][3] =   {{0,0,1}, {0,1,1}, {0,1,1}};
    int spiral6[][3] =   {{0,0,0}, {0,1,1}, {0,1,1}};
    int spiral7[][3] =   {{0,0,0}, {0,1,0}, {0,1,1}};
    int spiral8[][3] =   {{0,0,0}, {0,1,0}, {0,1,0}};
    int spiral9[][3] =   {{0,0,0}, {0,1,0}, {0,0,0}};
    int spiral10[][3] =  {{0,0,0}, {0,0,0}, {0,0,0}};
    
    int number = 0;
    int mode = 0;
    
    void setup() {
      for(int i = 0; i < 7; i++){
        if (i < 4){
          pinMode(cathode[i], OUTPUT);
          digitalWrite(cathode[i], LOW);
        }
        else{
          pinMode(anode[i], OUTPUT);
          digitalWrite(anode[i], LOW);
        }
      }
    }
    
    void loop() {
      number++;
      switch(mode){
        case(0):
          switch(number){
            case(1):
              writeMatrix(one, 100);
              break;
            case(2):
              writeMatrix(two, 100);
              break;
            case(3):
              writeMatrix(three, 100);
              break;
            case(4):
              writeMatrix(four, 100);
              break;
            case(5):
              writeMatrix(five, 100);
              break;
            case(6):
              writeMatrix(six, 100);
              number = 0;
              mode = 1;
              break;
            off();
          }
        break;
        case(1):
          switch(number){
            case(1):
              writeMatrix(spiral1, 15);
              break;
            case(2):
              writeMatrix(spiral2, 15);
              break;
            case(3):
              writeMatrix(spiral3, 15);
              break;
            case(4):
              writeMatrix(spiral4, 15);
              break;
            case(5):
              writeMatrix(spiral5, 15);
              break;
            case(6):
              writeMatrix(spiral6, 15);
              break;
            case(7):
              writeMatrix(spiral7, 15);
              break;
            case(8):
              writeMatrix(spiral8, 15);
              break;
            case(9):
              writeMatrix(spiral9, 15);
              break;
            case(10):
              writeMatrix(spiral10, 15);
              number = 0;
              mode = 2;
              break;
            off();
          }
        break;
            case(2):
          switch(number){
            case(1):
              writeMatrix(spiral10, 15);
              break;
            case(2):
              writeMatrix(spiral9, 15);
              break;
            case(3):
              writeMatrix(spiral8, 15);
              break;
            case(4):
              writeMatrix(spiral7, 15);
              break;
            case(5):
              writeMatrix(spiral6, 15);
              break;
            case(6):
              writeMatrix(spiral5, 15);
              break;
            case(7):
              writeMatrix(spiral4, 15);
              break;
            case(8):
              writeMatrix(spiral3, 15);
              break;
            case(9):
              writeMatrix(spiral2, 15);
              break;
            case(10):
              writeMatrix(spiral1, 15);
              number = 0;
              mode = 0;
              break;
            off();
          }
        break;
      }
    }
    
    void writeMatrix(int frame[][3], int time){
      for(int j = 0; j < time; j++){
        for(int i = 0; i < 3; i++){
          digitalWrite(cathode[0], frame[i][0]); 
          digitalWrite(cathode[1], frame[i][1]); 
          digitalWrite(cathode[2], frame[i][2]); 
          digitalWrite(anode[i], HIGH);
          delay(1);
          digitalWrite(anode[i], LOW);
        }
      }
    }
    
    void off(){
      for(int i = 0; i < 3; i++)
        digitalWrite(anode[i], LOW);
    }
    Some close up the breadboard ans LED matrix.

    3 Not allowed! Not allowed!

  2. #2
    Nintendo Section Moderator PvtRyan's Avatar

    Badge

    Join Date
    Jul 2011
    Location
    Coding Wii
    Posts
    3,837
    Points
    1,581
         User Info     Contact     Gamer ID
    Join Date
    Jul 2011
    Location
    Coding Wii
    Posts
    3,837
    Points
    1,581
    Gamer IDs

    PSN ID: gamer_pvtryan Steam ID: pvtryan_cl Wii Code: PvtRyan

    Contact info:

    Youtube Channel: http://www.youtube.com/xPvtRyanx

    Default

    What's really cool is my class is learning about the JFETs, BJTs, UJTs etc.


    <PvtRyan used Tapatalk to make this Post>

    0 Not allowed! Not allowed!


    PS4 Profile:

  3. #3
    Art Corner Moderator MejaiDesigns's Avatar
    Join Date
    Jun 2012
    Posts
    3,997
    Points
    1,612
         User Info     Contact     Gamer ID
    Join Date
    Jun 2012
    Posts
    3,997
    Points
    1,612

    Contact info:

    Youtube Channel: http://www.youtube.com/ApexDesignsCL

    Default

    This is pretty cool! Seems confusing though!

    0 Not allowed! Not allowed!

  4. #4
    Desu Development
    Pomf pomf :3
    Fuck Sky's Avatar
    Join Date
    Sep 2013
    Location
    WOW ANIME MAN WOW
    Posts
    1,137
    Points
    1,687
         User Info     Contact     Gamer ID
    Join Date
    Sep 2013
    Location
    WOW ANIME MAN WOW
    Posts
    1,137
    Points
    1,687
    Gamer IDs

    Gamertag: Hexpresso PSN ID: WideDongWeary Steam ID: twitchhexpresso

    Contact info:

    Youtube Channel: http://www.youtube.com/ Kik Username: Wownicehack

    Default

    You've been impressing me lately.

    0 Not allowed! Not allowed!
    geadszf1231qewrg

  5. #5
    Member
    Xbox OG
    Kim Jong Un's Avatar

    Badge

    Join Date
    Jan 2013
    Location
    North Korea
    Posts
    530
    Points
    194
         User Info     Contact     Gamer ID
    Join Date
    Jan 2013
    Location
    North Korea
    Posts
    530
    Points
    194
    Gamer IDs

    Gamertag: xAmbushh

    Contact info:

    Youtube Channel: http://www.youtube.com/user/zLogiicSniping

    Default

    Kind of interesting

    0 Not allowed! Not allowed!
    Welp, time to nuke the US.



    Damn US blaming us for hacking sony, smh.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -10. The time now is 03:38 PM.
Powered by vBulletin®
Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.