Pages: [1]   Go Down
Author Topic: Need Help understanding binary code  (Read 1128 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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???
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27113
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

B01110000
B10001000,
B10001000,
B11111000,
B10001000,
B10001000,

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

I don't know about this
#define BA
seems like its missing the array sysmbol []
So maybe it should be:
Code:
#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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Have a read of this:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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();
}
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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"
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yea guess that was a silly question smiley
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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???
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: