Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pinguino MX220 with Olimex LoL LED matrix
11-07-2012, 12:42 PM, (This post was last modified: 11-07-2012, 02:14 PM by MarSch.)
#1
Pinguino MX220 with Olimex LoL LED matrix
Hi there,

this is a minimally modified sketch that allows to run the Arduino test code for the LoL matrix on the Pinguino MX220:

Code:
//**************************************************************//
//  Name    : LoL Shield Program                                //
//  Author  : Jimmie P Rodgers   www.jimmieprodgers.com         //
//  Date    : 22 DEC, 2009  Last update on 12/22/09             //
//            Modified to work with Pinguino by MarSch, 20120710//
//  Version : 0.1                                               //
//  Notes   : Uses Charlieplexing techniques to light up        //
//          : a matrix of 126 LEDs in a 9x14 grid               //
//          : project website: www.jimmieprodgers.com/openheart //
//**************************************************************//

int blinkdelay = 75; //75 This basically controls brightness. Lower is dimmer
int runspeed = 20;   //20 smaller = faster

#define pin13 13
#define pin12 12
#define pin11 11
#define pin10 10
#define pin09  9
#define pin08  8
#define pin07  7
#define pin06  6
#define pin05  5
#define pin04  4
#define pin03  3
#define pin02  2

const int pins[] = {
  pin13,pin12,pin11,pin10,pin09,pin08,pin07,pin06,pin05,pin04,pin03,pin02
};


const int ledMap[126][2] ={
{pin13, pin05},{pin13, pin06},{pin13, pin07},{pin13, pin08},{pin13, pin09},{pin13, pin10},{pin13, pin11},{pin13, pin12},{pin13, pin04},{pin04, pin13},{pin13, pin03},{pin03, pin13},{pin13, pin02},{pin02, pin13},
{pin12, pin05},{pin12, pin06},{pin12, pin07},{pin12, pin08},{pin12, pin09},{pin12, pin10},{pin12, pin11},{pin12, pin13},{pin12, pin04},{pin04, pin12},{pin12, pin03},{pin03, pin12},{pin12, pin02},{pin02, pin12},
{pin11, pin05},{pin11, pin06},{pin11, pin07},{pin11, pin08},{pin11, pin09},{pin11, pin10},{pin11, pin12},{pin11, pin13},{pin11, pin04},{pin04, pin11},{pin11, pin03},{pin03, pin11},{pin11, pin02},{pin02, pin11},
{pin10, pin05},{pin10, pin06},{pin10, pin07},{pin10, pin08},{pin10, pin09},{pin10, pin11},{pin10, pin12},{pin10, pin13},{pin10, pin04},{pin04, pin10},{pin10, pin03},{pin03, pin10},{pin10, pin02},{pin02, pin10},
{pin09, pin05},{pin09, pin06},{pin09, pin07},{pin09, pin08},{pin09, pin10},{pin09, pin11},{pin09, pin12},{pin09, pin13},{pin09, pin04},{pin04, pin09},{pin09, pin03},{pin03, pin09},{pin09, pin02},{pin02, pin09},
{pin08, pin05},{pin08, pin06},{pin08, pin07},{pin08, pin09},{pin08, pin10},{pin08, pin11},{pin08, pin12},{pin08, pin13},{pin08, pin04},{pin04, pin08},{pin08, pin03},{pin03, pin08},{pin08, pin02},{pin02, pin08},
{pin07, pin05},{pin07, pin06},{pin07, pin08},{pin07, pin09},{pin07, pin10},{pin07, pin11},{pin07, pin12},{pin07, pin13},{pin07, pin04},{pin04, pin07},{pin07, pin03},{pin03, pin07},{pin07, pin02},{pin02, pin07},
{pin06, pin05},{pin06, pin07},{pin06, pin08},{pin06, pin09},{pin06, pin10},{pin06, pin11},{pin06, pin12},{pin06, pin13},{pin06, pin04},{pin04, pin06},{pin06, pin03},{pin03, pin06},{pin06, pin02},{pin02, pin06},
{pin05, pin06},{pin05, pin07},{pin05, pin08},{pin05, pin09},{pin05, pin10},{pin05, pin11},{pin05, pin12},{pin05, pin13},{pin05, pin04},{pin04, pin05},{pin05, pin03},{pin03, pin05},{pin05, pin02},{pin02, pin05}
};

uint16_t BitMap[][9] = {
{1, 0, 0, 0, 0, 0, 0, 0, 0},
{3, 1, 0, 0, 0, 0, 0, 0, 0},
{7, 3, 1, 0, 0, 0, 0, 0, 0},
{15, 7, 3, 1, 0, 0, 0, 0, 0},
{31, 15, 7, 3, 1, 0, 0, 0, 0},
{63, 31, 15, 7, 3, 1, 0, 0, 0},
{127, 63, 31, 15, 7, 3, 1, 0, 0},
{255, 127, 63, 31, 15, 7, 3, 1, 0},
{511, 255, 127, 63, 31, 15, 7, 3, 1},
{1023, 511, 255, 127, 63, 31, 15, 7, 3},
{2047, 1023, 511, 255, 127, 63, 31, 15, 7},
{4095, 2047, 1023, 511, 255, 127, 63, 31, 15},
{8191, 4095, 2047, 1023, 511, 255, 127, 63, 31},
{16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63},
{16383, 16383, 8191, 4095, 2047, 1023, 511, 255, 127},
{16383, 16383, 16383, 8191, 4095, 2047, 1023, 511, 255},
{16383, 16383, 16383, 16383, 8191, 4095, 2047, 1023, 511},
{16383, 16383, 16383, 16383, 16383, 8191, 4095, 2047, 1023},
{16383, 16383, 16383, 16383, 16383, 16383, 8191, 4095, 2047},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 8191, 4095},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 8191},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16382, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16380, 16382, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16376, 16380, 16382, 16383, 16383, 16383, 16383, 16383, 16383},
{16368, 16376, 16380, 16382, 16383, 16383, 16383, 16383, 16383},
{16352, 16368, 16376, 16380, 16382, 16383, 16383, 16383, 16383},
{16320, 16352, 16368, 16376, 16380, 16382, 16383, 16383, 16383},
{16256, 16320, 16352, 16368, 16376, 16380, 16382, 16383, 16383},
{16128, 16256, 16320, 16352, 16368, 16376, 16380, 16382, 16383},
{15872, 16128, 16256, 16320, 16352, 16368, 16376, 16380, 16382},
{15360, 15872, 16128, 16256, 16320, 16352, 16368, 16376, 16380},
{14336, 15360, 15872, 16128, 16256, 16320, 16352, 16368, 16376},
{12288, 14336, 15360, 15872, 16128, 16256, 16320, 16352, 16368},
{8192, 12288, 14336, 15360, 15872, 16128, 16256, 16320, 16352},
{0, 8192, 12288, 14336, 15360, 15872, 16128, 16256, 16320},
{0, 0, 8192, 12288, 14336, 15360, 15872, 16128, 16256},
{0, 0, 0, 8192, 12288, 14336, 15360, 15872, 16128},
{0, 0, 0, 0, 8192, 12288, 14336, 15360, 15872},
{0, 0, 0, 0, 0, 8192, 12288, 14336, 15360},
{0, 0, 0, 0, 0, 0, 8192, 12288, 14336},
{0, 0, 0, 0, 0, 0, 0, 8192, 12288},
{0, 0, 0, 0, 0, 0, 0, 0, 8192},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{18000}
};

void setup() {
    blinkall(2); // useful for testing
    }

void loop() {
    // put your main code here, to run repeatedly:
  //sequenceon(); // useful for testing
  DisplayBitMap();
}

void turnon(int led) {
  int pospin = ledMap[led][0];
  int negpin = ledMap[led][1];
  pinMode (pospin, OUTPUT);
  pinMode (negpin, OUTPUT);
  digitalWrite (pospin, HIGH);
  digitalWrite (negpin, LOW);
}

void alloff() {
  // Set pins as inputs for Pinguino
  int i;
  for(i = 2; i <= 13; i++)
    pinMode(i, INPUT);

  //DDRD = B00000010;  // Arduino 0-7, bit 0 and 1 are RX/TX
  //DDRB = B00000000;  // Arduino 8-13
}

void DisplayBitMap()
{
  boolean run=true;
  byte frame = 0;
  byte line = 0;
  byte led = 0;
  int i = 0;
  unsigned long data;
  while(run == true) {
    for(i = 0; i < runspeed; i++)     {
      for(line = 0; line < 9; line++)       {
        data = BitMap[frame][line];  
        if (data==18000){
          run=false;
        }
        else for (led=0; led<14; ++led) {
          if (data & (1<<led)) {
            turnon((line*14)+led);
            delayMicroseconds(blinkdelay);
            alloff();
          }
          else {
            delayMicroseconds(blinkdelay);
          }
        }

      }
            
    } frame++;  
  }
}

void blinkall(int numblink) {
  int n, j, i;
  alloff();
  for(n = 0;n < numblink;n++)   {
    for(i = 0; i < runspeed; i++)     {
      for(j = 0; j < 126; j++)       {
        turnon(j);
        delayMicroseconds(blinkdelay);
        alloff();
      }
    }
    delay(500);
  }
}

void sequenceon() {
  int i;
  for(i = 0; i < 126; i++)   {
    turnon(i);
    delay(800);
    alloff();
    delay(800);
  }
}
Reply
26-01-2015, 10:32 PM,
#2
RE: Pinguino MX220 with Olimex LoL LED matrix
It works! (Unfortunately, my LOL shield appears to have a faulty LED though!)

Thanks for that - a nice example.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)