Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to access two dimentinal arraies which hold ASCII code,

how to access two dimentinal arraies which hold ASCII code,

how to access two dimentinal arraies which hold ASCII code,

i have written the following code i have used two dimentinal arries and i want each of the letters in ASCII code to be accessed as they are required by the print funtion. this program is used for an LCD i want to write in print funtion and want the outcome to be displayed in LCD. i dont think if im in the right track please help me.


char PRTFuntion (unsigned char*)
int CHARlength = 8;
char LCDByte = 0;
    for ( int LCDPage = 0 ; LCDPage <=3; LCDPage++) // going through the 4 pages of the

     for (int columnAD=0; columnAD<=79; columnAD++)
            outportb (CONTROLLATCH,0x04);
            outportb (CONTROLLATCH,0x05);
            outportb (CONTROLLATCH,0x04);

           outportb (DATALATCH, LCDByte);

           for ( int LCDByte=0; LCDByte<=5; LCDByte++)


char ASCII[27][6] =
      {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},    // space
      {0x1E, 0x68, 0x88, 0x68, 0x1E, 0x00 },     // 41 A
      {0xFE, 0x92, 0x92, 0x92, 0x6C, 0x00 },     // 42 B
      {0x38, 0x44, 0x82, 0x82, 0x44, 0x00 },     // 43 C
      {0xFE,0x82, 0x82, 0x44, 0x38, 0x0 },      // 44 D
      {0xFE,0x92, 0x92, 0x92,0x92, 0x00},       // 45 E
      {0xFE, 0x90,0x90, 0x80, 0x80, 0x00 },     // 46 F
      {0x38, 0x44,0x82, 0x82, 0x8A, 0x00},      // 47 G
      {0xFE, 0x10,0x10, 0x10, 0xFE, 0x00},      // 48 H
      {0x82,0x82, 0xFE, 0x82,0x82, 0x00 },      // 49 I
      {0x4, 0x2, 0x2,0x82,0xFE, 0x00},            // 4a J
      {0xFE, 0x10, 0x28, 0x44,0x82, 0x00},// 4b K           
      {0xFE,0x2, 0x2, 0x2, 0x2, 0x00}, // 4c L
      {0xFE, 0x40, 0x20, 0x40, 0xFE, 0x00},    // 4d M
      {0xFE,0x40, 0x38, 0x4, 0xFE, 0x00},      // 4e N
      {0x38, 0x44, 0x82, 0x44,0x38, 0x00},     // 4f O
      {0xFE, 0x90, 0x90, 0x90, 0x60, 0x00},    // 50 P
      {0x38, 0x44, 0x82, 0x44, 0x38, 0x00},    // 51 Q
      {0xFE, 0x90, 0x98, 0x94, 0x62, 0x00},    // 52 R
      {0x064, 0x92, 0x92, 0x92, 0x4C, 0x00},   // 53 S
      {0x80, 0x80, 0xFE, 0x80, 0x80, 0x00},    // 54 T
      {0xFC, 0x2, 0x2, 0x2,0xFC, 0x00},        // 55 U
      {0xE0, 0x1C, 0x2, 0x1C, 0xE0, 0x00},     // 56 V
      {0xFE, 0x4, 0x8, 0x4, 0xFE, 0x00},       // 57 W
      {0x82, 0x6C, 0x10, 0x6C, 0x82, 0x00},    // 58 X
      {0x80, 0x40, 0x3E, 0x40, 0x80, 0x00},    // 59 Y
      {0x86, 0x8A, 0x92, 0xA2, 0xC2, 0x00}};    // 5a Z

RE: how to access two dimentinal arraies which hold ASCII code,

Maybe something more like this would get you to the character you want.  (Ignoring the controllatch bytes, I am not fluent on the handshaking.)


void PRTFuntion (unsigned char* whatCharToPrint )
char* pLCDByte = 0;
// print on each "page" is each page a color ?
for ( int LCDPage = 0 ; LCDPage <=3; LCDPage++)
// going through the 4 pages of the
    // ignoring space char for now because space
    // is not next to 'A' in the ascii alphabet
    // access the first dimension of the array
    pLCDByte = ASCII[whatCharToPrint - 'A' + 1];
    // do the bytes making up the character
    for ( int idxByte=0; idxByte <= 5; idxByte++)
        // access the second dimension of the array
        outportb (DATALATCH, pLCDByte[idxByte] );

}   // end function

char ASCII[27][6] =  /* as above */


// another way to access a two dim array
int idxToChar = whatCharToPrint - 'A' + 1;
for( int idxByte=0; idxByte <= 5; idxByte++)
        // access both dimension of the array at once
        char toOutput = ASCII[idxToChar][idxByte];
        outportb (DATALATCH, toOutput );

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close