96 * 16 led dot matrix problem

Can anyone help arduino sketch? I will display 12 characters using 96 16 dot matrix ((1616 matrix)*6)

in attached sketch. Fifth matrix and sixth matrix display 9~ 12 characters and 1~4 characters alternatively.

ex:) Message " ABCDEFGHIJKL" … IJKL, ABCD alternatively

I will display this matrix two function. First is displaying fixed characters, seond is scrolling right to left.

First. It must be resolve the fifth and sixth matrix alternatively display.

I attacted fifth and sixth matrix displaying IJKL and ABCD. I wanna display only IJKL

and if scrolling right to left, how can I modify the sketch?

thank you

sketch file and matrix image files atttaced…

#include <avr/pgmspace.h>
#include “pins_arduino.h”
// based on myMatrix Arduino Library
// by Silviu - www.openhardware.ro
// MIT License (MIT)
// Connections to board

const byte pinSTB=9;
const byte pinClock=8;
const byte pinRed=6;
const byte pinGreen=7;
const byte pinOE=10;
const byte pinRowA=2;
const byte pinRowB=3;
const byte pinRowC=4;
const byte pinRowD=5;
byte scanRow = 0;
unsigned long counter;

//Insert message here ("message ")
char message = “ABCDEFGHIJKLMNOPQRSTUVW”;

// ---------------------------------------------------------------------------------------------------
const byte RED = 0b01;
const byte GREEN = 0b10;
const byte YELLOW = 0b00;
const byte BLACK = 0b11;

struct Color {
byte R;
byte G;
};

#define BUFFER_INIT_256 BUFFER_INIT_100 BUFFER_INIT_10 BUFFER_INIT_10 BUFFER_INIT_8
#define BUFFER_INIT_100 BUFFER_INIT_50 BUFFER_INIT_50
#define BUFFER_INIT_50 BUFFER_INIT_10 BUFFER_INIT_10 BUFFER_INIT_10 BUFFER_INIT_10 BUFFER_INIT_10
#define BUFFER_INIT_10 BUFFER_INIT_2 BUFFER_INIT_2 BUFFER_INIT_2 BUFFER_INIT_2 BUFFER_INIT_2
#define BUFFER_INIT_8 BUFFER_INIT_2 BUFFER_INIT_2 BUFFER_INIT_2 BUFFER_INIT_2
#define BUFFER_INIT_2 BUFFER_INIT_1 BUFFER_INIT_1
#define BUFFER_INIT_1 {0x00, 0x00},

Color buffer[256] = {BUFFER_INIT_256};

// ---------------------------------------------------------------------------------------------------

// FONTS sourced from various locations on the internet
// full ASCII character set (8x16) (1520 bytes)

static const uint8_t font16x16_basic[16] PROGMEM = {

}

// function to colorize a pixel
// color 2 Bit, (R)ed (G)reen 0b000000RG

void setPixel(uint8_t x ,uint8_t y, uint8_t color) //uint8_t =byte (x, y, color)

{
byte myindex; // oringin(y+x/8;8 segments per row
byte mybitmask;

{
myindex = (y*8)+x/8;
mybitmask = 7 -(x % 8);
bitWrite(buffer[myindex].R, mybitmask, (color& 0b00000010)); // buffer(),R = x, mybitmask = n
bitWrite(buffer[myindex].G, mybitmask, (color& 0b00000001));
}

}

// function to print a character at column
// this means text starts in upper left corner
void printChar(uint8_t x_offset, uint8_t fg_color, uint8_t bg_color, byte ch) {

if (0 != (x_offset % 8)) return; // x_offset not a multiple of 8
if ((ch>9) && (ch<32)) return; // invalid character
const uint8_t y_offset = 0;
for (uint8_t y=0; y<16; y++){
for (uint8_t i=0; i<8; i++){
if(bitRead(pgm_read_byte(&font16x16_basic[ch-32][y]),i)) setPixel(x_offset+i, y_offset+y, fg_color);
else setPixel(x_offset+i, y_offset+y, bg_color);
}
}

}

// function to scrol the text message to the left

void hScroll(uint8_t fg_color, uint8_t bg_color, char *mystring)
{
// offset starts with 0
// this means text starts in upper left corner
// Serial.println(lenString(mystring));

for (int offset= ((lenString(mystring)-8)*8-1); offset >0 ; offset–) {
for (byte x=0; x<96; x++){
for (byte y=0; y<16; y++){
byte color=bg_color;
if (getPixelMessage(x,y,mystring)) color=fg_color;
setPixel(x,y,color);
}
}
delay(40);
}
}

byte getPixelMessage(uint8_t x, uint8_t y, char *p){
p=p+x/8;

return getPixelChar(x%8, y, *p);
}

byte getPixelChar(byte x, uint8_t y, char ch){

return bitRead(pgm_read_byte(&font16x16_basic[ch-32][y]),x);
}

// length of the message string

uint8_t lenString(char *p){
unsigned int retVal=0;
while(*p!=’\0’){
retVal++;
p++;

}
return retVal;
}

void clearScreen(){
for (uint8_t i=0; i<256; i++) // buffer size
{
buffer*.R=0;*
_ buffer*.G=0;_
delay (2);
_
}_
_
}_
_
// helper function to paint one row*_
void shiftOut(uint8_t row) {
const uint8_t bitRed = digitalPinToBitMask(pinRed);
volatile uint8_t *outRed = portOutputRegister(digitalPinToPort(pinRed));
const uint8_t bitGreen = digitalPinToBitMask(pinGreen);
volatile uint8_t *outGreen = portOutputRegister(digitalPinToPort(pinGreen));
const uint8_t bitClock = digitalPinToBitMask(pinClock);
volatile uint8_t *outClock = portOutputRegister(digitalPinToPort(pinClock));
const uint8_t bitRowA = digitalPinToBitMask(pinRowA);
volatile uint8_t *outRowA = portOutputRegister(digitalPinToPort(pinRowA));
const uint8_t bitRowB = digitalPinToBitMask(pinRowB);
volatile uint8_t *outRowB = portOutputRegister(digitalPinToPort(pinRowB));
const uint8_t bitRowC = digitalPinToBitMask(pinRowC);
volatile uint8_t *outRowC = portOutputRegister(digitalPinToPort(pinRowC));
const uint8_t bitRowD = digitalPinToBitMask(pinRowD);
volatile uint8_t *outRowD = portOutputRegister(digitalPinToPort(pinRowD));
const uint8_t bitOE = digitalPinToBitMask(pinOE);
volatile uint8_t outOE = portOutputRegister(digitalPinToPort(pinOE));
const uint8_t bitSTB = digitalPinToBitMask(pinSTB);
volatile uint8_t outSTB = portOutputRegister(digitalPinToPort(pinSTB));
*outOE |= bitOE; // Turn off display // digitalWrite(pinOE,HIGH);
_
// select row
_
if (bitRead(row, 0)) *outRowA |= bitRowA; else *outRowA &= ~bitRowA;
if (bitRead(row, 1)) *outRowB |= bitRowB; else *outRowB &= ~bitRowB;
if (bitRead(row, 2)) *outRowC |= bitRowC; else *outRowC &= ~bitRowC;
if (bitRead(row, 3)) *outRowD |= bitRowD; else *outRowD &= ~bitRowD;

for(uint8_t column=0; column<12; column++){ // 8 segments
uint8_t index = column + (row8); // 8 segments
for(uint8_t i=0; i<8; i++) {
_ if (buffer[index].R & (1<<(7-i))) outRed &= ~bitRed;
else outRed |= bitRed;
if (buffer[index].G & (1<<(7-i))) outGreen &= ~bitGreen;
else outGreen |= bitGreen;_
_
//Clock Pulse
_
_ outClock |= bitClock; //CLK, HIGH_
_ outClock &= ~bitClock; //CLK, LOW_
_
}
_
_
}
_
*outSTB &= ~bitSTB; // digitalWrite(pinSTB,LOW);
*outSTB |= bitSTB; // digitalWrite(pinSTB,HIGH);
*outOE &= ~bitOE; // Turn on display // digitalWrite(pinOE,LOW);
_
}_
_
// interrupt routine is responsible for painting the screen*_
ISR(TIMER2_COMPA_vect){
cli();
shiftOut(scanRow);
if (scanRow < 15) scanRow++; else scanRow = 0;
sei();
}
void setup() {
// use timer2 as the scanning interrupt timer
cli(); // clear interrupts
TCCR2A = 0; TCCR2B = 0; TCNT2 = 0;
TCCR2B |= (1 << CS12) | (1 << CS10); // Set 1024 prescaler
* // 160Hz scan rate = 10 frames/second (16 rows)*
OCR2A = 97; // 97 = (16,000,000 / (1024*160)) - 1
TCCR2A |= (1 << WGM21); TIMSK2 |= (1 << OCIE2A);
pinMode(pinRed, OUTPUT);
pinMode(pinGreen, OUTPUT);
pinMode(pinClock, OUTPUT);
pinMode(pinRowA, OUTPUT);
pinMode(pinRowB, OUTPUT);
pinMode(pinRowC, OUTPUT);
pinMode(pinRowD, OUTPUT);
pinMode(pinOE, OUTPUT);
pinMode(pinSTB, OUTPUT);
digitalWrite(pinOE, LOW);
digitalWrite(pinRed, HIGH); digitalWrite(pinGreen, HIGH);
sei(); //allow interrupts
Serial.begin(9600);
}
// main loop is responsible for updating the screen
*void loop() { *
// printChar(0,GREEN,BLACK,‘A’);
hScroll(RED, BLACK, message);
}
abcd.JPG
ijkl.JPG
matrix_1229.ino (17.5 KB)

If you want help, you must first read this, especially points 7 & 9. Then fix your post above.

Thank you for your advise..I'll do it~