Hi, i've just attached a 5x7 Matrix to my arduino and been successful to control it using a few example projects i found around the forum.
Now i'm trying to Customize the code to display frames received through serial port.
for now i'm using "FrequencyTimer2" for interrupts, i've also read about the TimerOne library...can anyone advise me as to which one would be better for the job?
The idea was to sent picture information row by row as one byte per row in the form of
'00000', (0)
'11111', (31)
....
with some value like 255 as a new frame signal.
(there is no code for any serial transmission yet since i haven't figured out the strategy for synchronizing the frame transfer from the processing output with my arduino input)
i'm stuck in the early beginning while translating the binary values to individual pixels per column.
i've read the bitmask tutorial at http://www.arduino.cc/en/Tutorial/BitMask
after trying to adapt it to my needs i seem to get jibberish for the output (which probably results from mistakes on my part ^^)
here's what i've got so far:
#include <FrequencyTimer2.h>
/**/
const int rows[] = { 1,2,3,4,5,6,7 };
const int cols[] = { 8, 9, 10, 11, 12 };
const int NUM_COLS = 5;
const int NUM_ROWS = 7;
void setup()
{
// initialize output pins
for (int c = 0; c < NUM_COLS; c++)
{
pinMode(cols[c], OUTPUT);
digitalWrite(cols[c], LOW);
}
for (int r = 0; r < NUM_ROWS; r++)
{
pinMode(rows[r], OUTPUT);
digitalWrite(rows[r], LOW);
}
// configure frequencyTimer2
FrequencyTimer2::disable();
FrequencyTimer2::setPeriod(2000);
FrequencyTimer2::setOnOverflow(refresh);
}
// test-buffer
byte buffer[NUM_ROWS] = {
11111,
11111,
11111,
11111,
11111,
11111,
11111
};
int col = NUM_COLS - 1;
int row = NUM_ROWS - 1;
void refresh()
{
digitalWrite(rows[row], HIGH);
row++;
if (row >= NUM_ROWS)
row = 0;
byte mask = 10000;
for (int col = 0; col < NUM_COLS; col++){
digitalWrite(cols[col], (buffer[row] & mask) ? HIGH : LOW); // this is where i screw up, is it?? ^^
mask >>= 1;
}
digitalWrite(rows[row], LOW);
}
void loop()
{
delay(1000);
}
thanks to anyone who is willing to help ![]()