[dorkbotpdx-blabber] 5x5 matrix code help

m sanders modularduck at yahoo.com
Fri Mar 6 18:23:01 EST 2009


Its just the standard arduino core i believe. i mean i went into tool and switch to decimelia but it is the version of the software that i changed for use with the sanguino perhaps i should try using the copy i made? or maybe i should just bite bullet and update to 13. i wouldnt think that they (arduino) would post bad code in the examples since this was taken directly from the "direct driving an 8x8 led matrix" under the outputs section. but im sure its possible. thansk for the help!

michael



________________________________
From: Donald Delmar Davis <ddelmardavis at gmail.com>
To: "A discussion list for dorkbot-pdx (portland,  or)" <dorkbotpdx-blabber at dorkbot.org>
Sent: Friday, March 6, 2009 1:18:53 PM
Subject: Re: [dorkbotpdx-blabber] 5x5 matrix code help

Is this the stock arduino (as apposed to the sanguino core on top of the stock arduino)?
If so this is a bug and should be taken up with them. 
If I get time this afternoon I will compile this code on the latest rev 13.

Are we having fun yet?

Don.




On Mar 6, 2009, at 10:35 AM, m sanders wrote:

Don and Greg, 

well i know that the display is fully functional i can load the 3x3x3 led cube code and adjust the pins accordingly and get it to work just fine all be it in no paticular order to flashes of leds but thats purely due to the fact that its meant for 3d application and not for a 2d matrix, nonetheless i does confirm the funtionality of the display. 

i am using arduino 12 software and the standard atmel 168 that comes with dorkboard and here are the error messages i get when i try to compile:


In file included from /arduino-0012/hardware/cores/arduino/WProgram.h:4,

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:80: error: expected `)' before 'int'

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:80: error: expected `)' before 'int'

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:144: error: expected identifier before '(' token

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:144: error: expected `)' before '(' token

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:144: error: expected ',' or '...' before '(' token

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:144: error: expected initializer before ')' token

/arduino-0012/hardware/tools/avr/bin/../lib/gcc/avr/4.3.0/../../../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared

In file included from /arduino-0012/hardware/cores/arduino/WProgram.h:6,


interesting side note if i cant seem to compile the original code from arduino website here is linky :  http://www.arduino.cc/playground/Main/DirectDriveLEDMatrix?action=sourceblock&ref=1

i get the exact same error messages seems kinda weird, and i have no problem with reloading the 3x3x3 led cube code into chip. perhaps its time to break out the banana peals and see if i can wrap my head around this one.  also i tried to add "(" and ")" around the "int" in all kinds of variations to debug but nothing seemed to work for me. thanks

michael





________________________________
From: Greg Grunest <greg at grunest.com>
To: "A discussion list for dorkbot-pdx (portland, or)" <dorkbotpdx-blabber at dorkbot.org>
Sent: Friday, March 6, 2009 8:50:01 AM
Subject: RE: [dorkbotpdx-blabber] 5x5 matrix code help


Hey,
What board / chip are you using?
 

Also, what are the exact errors? 
 

I tried your program and if I attempt to compile for an Arduino with an Atmel 328, I get errors in line 51 & 52 of FrequencyTimer2.cpp.  I know why this is happening but I don’t know how to fix it “elegantly”.  If this is your problem and you want my “kludge”, I’ll send it to you.
 

Original code from FrequencyTimer2.cpp
 

47: #if defined(__AVR_ATmega168__)
48:    if ( func) TIMSK2 |= _BV(OCIE2A);
49:    else TIMSK2 &= ~_BV(OCIE2A);
50: #else
51:    if ( func) TIMSK |= _BV(OCIE2);
52:    else TIMSK &= ~_BV(OCIE2);
53: #endif
 

Or if another list reader has a good understanding of the inner workings of the Arduino environment and cpp, maybe they could look at it and spare me the shame of distributing a kludge. ;)
 

 

 

Then, I tried to compile if for an Arduino with a 168 and I get errors in stdlib.h line 111.  I looked at the line of code in stdlib.h and I can’t see anything wrong with it.  Hmm…
 

Stdlib.h:111
/** The abs() function computes the absolute value of the integer \c i.
   \note The abs() and labs() functions are builtins of gcc.
*/
extern int abs(int __i) __ATTR_CONST__;
 

 

Then again, maybe you’re getting a completely different set of errors.  It’s entirely possible.  So knowing what error you’re getting and where would really help.
 

- Greg
 

 


________________________________

From: dorkbotpdx-blabber-bounces at dorkbot.org [mailto:dorkbotpdx-blabber-bounces at dorkbot.org] On Behalf Of m sanders
Sent: Thursday, March 05, 2009 9:40 PM
To: dorkbotpdx-blabber at dorkbot.org
Subject: [dorkbotpdx-blabber] 5x5 matrix code help
 

Hey all, so i am new to the whole cult thing and am needing some help with some code i am tryin to adapt from the arduino site to make this 5x5 matrix work directly off dork board problem is that there are errors and im not savvy enough with programming to work it out, more of a production kinda guy not so much a software kinda guy. anyway i digress and will thank you all in advance for any help you might be about to give me. 
 

michael
 

here is code. also as a side not you can seei jusr shortened the defined space and changed row and column things to reflec the size of my matrix. there is a part in the code that speaks of pin 11 and i am not using it so maybe thats one problem but, the error messages have no mention of this, and i have installed all libraries in the correct locations and everything. or anyone have some 5x5 code layin around? thanks again!
 

/*
 * Show messages on an 5x5 led matrix,
 * scrolling from right to left.
 * 
 * Uses FrequencyTimer2 library to
 * constantly run an interrupt routine
 * at a specified frequency. This
 * refreshes the display without the
 * main loop having to do anything.
 *
 */
 

#include <FrequencyTimer2.h>
 

#define SPACE { \
    {0, 0, 0, 0, 0},  \
    {0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0}, \
  

}
 

#define H { \
    {1, 0, 0, 0, 1}, \
    {1, 0, 0, 0, 1}, \
    {1, 1, 1, 1, 1}, \
    {1, 0, 0, 0, 1}, \
    {1, 0, 0, 0, 1}, \
    

}
 

#define E  { \
    {1, 1, 1, 1, 1}, \
    {1, 0, 0, 0, 0}, \
    {1, 1, 1, 0, 0}, \
    {1, 0, 0, 0, 0}, \
    {1, 1, 1, 1, 1}, \
    

}
 

#define L { \
    {1, 0, 0, 0, 0}, \
    {1, 0, 0, 0, 0}, \
    {1, 0, 0, 0, 0}, \
    {1, 0, 0, 0, 0}, \
    {1, 1, 1, 1, 1}, \
    

}
 

#define O { \
    {0, 1, 1, 1, 0}, \
    {1, 0, 0, 0, 1}, \
    {1, 0, 0, 0, 1}, \
    {1, 0, 0, 0, 1}, \
    {0, 1, 1, 1, 0}, \
    

}
 

byte col = 0;
byte leds[5][5];
 

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[11]= {-1, 4, 3, 14, 17, 13, 12, 10, 9, 8, 6};
 

// col[xx] of leds = pin yy on led matrix
int cols[5] = {pins[13], pins[3], pins[4], pins[10], pins[06]};
 

// row[xx] of leds = pin yy on led matrix
int rows[5] = {pins[9], pins[14], pins[8], pins[12], pins[1]};
 

const int numPatterns = 6;
byte patterns[numPatterns][5][5] = {
  H,E,L,L,O,SPACE
};
 

int pattern = 0;
 

void setup() {
  // sets the pins as output
  for (int i = 1; i <= 10; i++) {
    pinMode(pins[i], OUTPUT);
  }
 

  // set up cols and rows
  for (int i = 1; i <= 5; i++) {
    digitalWrite(cols[i - 1], LOW);
  }
 

  for (int i = 1; i <= 5; i++) {
    digitalWrite(rows[i - 1], LOW);
  }
 

  clearLeds();
 

  // Turn off toggling of pin 11
  FrequencyTimer2::disable();
  // Set refresh rate (interrupt timeout period)
  FrequencyTimer2::setPeriod(2000);
  // Set interrupt routine to be called
  FrequencyTimer2::setOnOverflow(display);
 

  setPattern(pattern);
}
 

void loop() {
    pattern = ++pattern % numPatterns;
    slidePattern(pattern, 60);
}
 

void clearLeds() {
  // Clear display array
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      leds[i][j] = 0;
    }
  }
}
 

void setPattern(int pattern) {
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      leds[i][j] = patterns[pattern][i][j];
    }
  }
}
 

void slidePattern(int pattern, int del ) {
  for (int l = 0; l < 5; l++) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 5; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    for (int j = 0; j < 5; j++) {
      leds[j][4] = patterns[pattern][j][0 + l];
    }
    delay( del );
  }
}
 

// Interrupt routine
void display() {
  digitalWrite(cols[col], LOW);  // Turn whole previous column off
  col++;
  if (col == 5) {
    col = 0;
  }
  for (int row = 0; row < 5; row++) {
    if (leds[col][4 - row] == 1) {
      digitalWrite(rows[row], LOW);  // Turn on this led
    }
    else {
      digitalWrite(rows[row], HIGH); // Turn off this led
    }
  }
  digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
  delayMicroseconds(900);  // Delay so that on times are longer than off time = brighter leds
}
 

_______________________________________________
dorkbotpdx-blabber mailing list
dorkbotpdx-blabber at dorkbot.org
http://music.columbia.edu/mailman/listinfo/dorkbotpdx-blabber



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://music.columbia.edu/pipermail/dorkbotpdx-blabber/attachments/20090306/e3a23323/attachment-0001.html


More information about the dorkbotpdx-blabber mailing list