Go Down

### Topic: Need Help understanding binary code (Read 2588 times)previous topic - next topic

#### bigbuck83

##### Oct 15, 2013, 02:32 pm
Hello everyone I am a little confused about how to right a text in binary code that will display on a 24x6 matrix I am using this indestructible as a guide              http://www.instructables.com/id/Make-a-24X6-LED-matrix/                what I don't understand is how the message is written in binary code........... take the looping text sketch for example  the first line  reads ........ ...........................             #define BA {B01110000,B10001000,B10001000,B11111000,B10001000,B10001000} ........is this supposed to be the capital letter "A" displayed on the matrix?? ............once I translate this line it means ......"p??ΓΈ??" what does this first line really do on the matrix???

#1
##### Oct 15, 2013, 03:34 pm
B01110000
B10001000,
B10001000,
B11111000,
B10001000,
B10001000,

Look at the shape the 1s make - looks like an A to me.

#define BA
seems like its missing the array sysmbol []
So maybe it should be:
Code: [Select]

#define BA [] = {
B01110000,
B10001000,
B10001000,
B11111000,
B10001000,
B10001000,
};

Could put that in PROGMEM too.

Bet it could be condensed too - notice the amount of redundancy? Elements  1,2,4,5 are all the same, and no doubt elements 0 and 3 are in common with other letters.
So you could probably define 16 elements that make up any letter, and reduce each letter to 3 bytes: byte 0 represents rows 0,1, byte 1 represents rows 2,3 and byte 3 represents rows 4,5.

0x01 = B01110000,
0x01 = B10001000
0x02= B11111000
etc up to 0x0F

So an A for instance might be
{0x0001, 0x0102, 0x0101}

and the data decoded/looked up on the fly.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### Grumpy_Mike

#2
##### Oct 15, 2013, 03:43 pm
Quote
Look at the shape the 1s make - looks like an A to me.

It would look a lot better in a mono spaced font.

http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

#### bigbuck83

#3
##### Oct 15, 2013, 08:50 pm
ok I see it now.............. now where in the sketch would the text that I want to display be added??? obviously in this area but where exactly

int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int latchPinPORTB = latchPin - 8;
int clockPinPORTB = clockPin - 8;
int dataPinPORTB = dataPin - 8;
int i = 0;
long scrolling_word[6];
int array_turn=0;
byte your_text[8][6]={BH,BI,SPACE,BW,BO,BR,BL,BD};//PUT YOU TEXT HERE

void setup(){
Serial.begin(9600);
pinMode(dataPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(latchPin,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(Reset,OUTPUT);
digitalWrite(Reset,HIGH);
digitalWrite(Reset,LOW);
setupSPI();
}

#### Grumpy_Mike

#4
##### Oct 15, 2013, 11:07 pm
Quote
now where in the sketch would the text that I want to display be added??

Here is a clue. Where it says "put your text here"

#### bigbuck83

#5
##### Oct 16, 2013, 12:28 am
yea guess that was a silly question

#### bigbuck83

#6
##### Oct 16, 2013, 01:37 am
ok a real question......... how long can a message be for example when I try and say "Merry Christmas" I get an error saying the text is to big for [8][6]..............what am I missing???

#### Grumpy_Mike

#7
##### Oct 16, 2013, 05:01 pm

ok a real question......... how long can a message be for example when I try and say "Merry Christmas" I get an error saying the text is to big for [8][6]..............what am I missing???

That array is the whole size of your matrix, if your message is longer then you have to make that array bigger.
It will still only show the first half of your message.
You could split it up into two arrays of 8 by 6 and flash one then the other. That is the simplest thing to do.

The other thing is to look at scrolling your display. This involves adding an offset to the array every so often so that it is displayed in a different position.

Go Up