HD66717 code (WD-C2401P)

I have 1 of these 24x1 LCD displays that I would like to use in a project.
I followed the advice here and quickly got it going.
I now would like to print a custom character but can not figure out how to do it.

I attached a datasheet that I found.

Can anybody please give me some advice?

Thank you for any assistance.

LCD-111(1).pdf (1.31 MB)

This is the code that I am working with, all works 100% except the custom character part:

unsigned char lock[]= {0x0E,0x11,0x11,0x1F,0x1B,0x1B,0x1F,0x00};    // lock
unsigned char smiley[]= {0x00,0x00,0x0A,0x00,0x00,0x11,0x0E,0x00};  // smiley
unsigned char sleepy[]= {0x00,0x00,0x0A,0x00,0x00,0x1F,0x00,0x00};  // sleepy
unsigned char heart[]= {0x00,0x0a,0x1F,0x1F,0x0E,0x04,0x00,0x00};   // heart

class WDC2401P
{
private:
 byte _rs_pin;      // define RS Arduino pin #
 byte _enable_pin;  // define enable Arduino pin #
 byte _data_pin0;   // define D0 Arduino pin #
 byte _data_pin1;   // define D1 Arduino pin # 
 byte _data_pin2;   // define D2 Arduino pin #
 byte _data_pin3;   // define D3 Arduino pin #
 byte _data_pin4;   // define D4 Arduino pin #
 byte _data_pin5;   // define D5 Arduino pin #
 byte _data_pin6;   // define D6 Arduino pin #
 byte _data_pin7;   // define D7 Arduino pin #   

 WDC2401P& WriteCommand(byte Command = 0x01)  // The following code writes a command to the LCD
 { 
   digitalWrite(_rs_pin, LOW);                // set LCD RS pin low for sending commands 
   digitalWrite(_data_pin0, Command & 0x01);  // set LCD bit d0 
   digitalWrite(_data_pin1, Command & 0x02);  // set LCD bit d1 
   digitalWrite(_data_pin2, Command & 0x04);  // set LCD bit d2
   digitalWrite(_data_pin3, Command & 0x08);  // set LCD bit d3 
   digitalWrite(_data_pin4, Command & 0x10);  // set LCD bit d4 
   digitalWrite(_data_pin5, Command & 0x20);  // set LCD bit d5 
   digitalWrite(_data_pin6, Command & 0x40);  // set LCD bit d6 
   digitalWrite(_data_pin7, Command & 0x80);  // set LCD bit d7
   digitalWrite(_enable_pin, HIGH);   // set LCD Enable High 
   delay(2);
   digitalWrite(_enable_pin, LOW);    // set LCD Enable low - This should latch data
   delay(20);                         // A little delay to allow command to implament
 }

 WDC2401P& WriteData(byte Data = 0x01)     // The following code writes data to the LCD
 { 
   digitalWrite(_rs_pin, HIGH);            // set LCD RS pin low for sending commands 
   digitalWrite(_data_pin0, Data & 0x01);  // set LCD bit d0 
   digitalWrite(_data_pin1, Data & 0x02);  // set LCD bit d1 
   digitalWrite(_data_pin2, Data & 0x04);  // set LCD bit d2
   digitalWrite(_data_pin3, Data & 0x08);  // set LCD bit d3 
   digitalWrite(_data_pin4, Data & 0x10);  // set LCD bit d4 
   digitalWrite(_data_pin5, Data & 0x20);  // set LCD bit d5 
   digitalWrite(_data_pin6, Data & 0x40);  // set LCD bit d6 
   digitalWrite(_data_pin7, Data & 0x80);  // set LCD bit d7
   digitalWrite(_enable_pin, HIGH);        // set LCD Enable High 
   delay(1);
   digitalWrite(_enable_pin, LOW);         // set LCD Enable low - This should latch data
   delay(1);
 }

public:  
 WDC2401P(byte _rs=13, byte _en=12,
          byte _d0=11, byte _d1=10,
          byte _d2=9,  byte _d3=8,
          byte _d4=7,  byte _d5=6,
          byte _d6=5,  byte _d7=4) :
   _rs_pin(_rs),      // define RS Arduino pin #
   _enable_pin(_en),  // define enable Arduino pin #
   _data_pin0(_d0),   // define D0 Arduino pin #
   _data_pin1(_d1),   // define D1 Arduino pin # 
   _data_pin2(_d2),   // define D2 Arduino pin #
   _data_pin3(_d3),   // define D3 Arduino pin #
   _data_pin4(_d4),   // define D4 Arduino pin #
   _data_pin5(_d5),   // define D5 Arduino pin #
   _data_pin6(_d6),   // define D6 Arduino pin #
   _data_pin7(_d7)    // define D7 Arduino pin #   
 {
 }
 
 void Initialize()
 {    
   pinMode(_rs_pin, OUTPUT);
   pinMode(_enable_pin, OUTPUT);
   pinMode(_data_pin0, OUTPUT);
   pinMode(_data_pin1, OUTPUT);
   pinMode(_data_pin2, OUTPUT);
   pinMode(_data_pin3, OUTPUT);
   pinMode(_data_pin4, OUTPUT);
   pinMode(_data_pin5, OUTPUT);
   pinMode(_data_pin6, OUTPUT);
   pinMode(_data_pin7, OUTPUT);
   
   digitalWrite(_enable_pin, LOW);    // set LCD Enable low to start

   // The following code turns on the LCD driver power
   WriteCommand(0x1C);
   delay(200);                        // delay added to allow LCD time to boot up

   // The following code sets the LCD cursor to non blinking
   WriteCommand(0x08);

   // The following code turns on the LCD character display
   WriteCommand(0x14);

   // The following code sets the LCD display to 1 line 
   WriteCommand(0x28);

   // The following code sets the LCD contrast to high 
   WriteCommand(0x4F);
 }

 void Clear()
 {
   // The following code clears the LCD display and sets DRAM addr 0 in addr counter
   WriteCommand(0x01);
   delay(20);                          // A little delay to allow display to clear
 }
 
 void CursorPos(byte location)
 {
   // Not sure what happened here, but at 16 and above the address steps backwards
   if (location > 15)
   {
     location=location+4;             // This seems messed up but it works
   } 
   if (location > 23 || location < 0) // check for location outside display range
   {
     location = 24;                   // set location of first char outside display range
   }
   location = location + 0xE0;        // add LCD cursor location address (0xE0) to location
   WriteCommand(location);            // Send command to move cursor to selected location
 }

 void PrintChar(char *c_Text)
 {
   char c_Temp;                                                       // Temp holder for character to display
   // The following code prints the characters to LCD
   for (int i = 0; i < 23; i++) {
     c_Temp = *(c_Text+i);
     if (c_Temp == '\0') {
       i=24;
     }
     else
     {
       WriteData(c_Temp);
     }
   }
 }

void PrintCharx(byte cData)
 {
     WriteData(cData);
    
 }

 void PrintCharz(char cData)
 {
     WriteData(cData);
         
 }

void CreateCustomCharacter (const char loc, unsigned char *pattern)
{ 
 int i = 0;
   if(loc<8)                            //If valid address
   {
       WriteCommand(0xA0+(loc*8));      //Write to CGRAM
       for(i=0; i<8; i++)
       {
         
          WriteData(pattern[i]);       //Write the character pattern to CGRAM
          
       }  
          WriteCommand(0xE0);          // return to sending data into the standard string buffer.
   }
}
//**************************************************************
 

};
// END OF WDC2401P CLASS //////////////////////////////////////////////


// Setup the LCD Class and interface pins as defined below
// WDC2401P LCD(RS, EN, D0, D1, D2, D3, D4, D5, D6, D7)
WDC2401P LCD(13, 12, 10, 9, 8, 7, 6, 5, 4, 3);  



void setup() 
 {

//********************************************************************
LCD.CreateCustomCharacter(0,lock);           
LCD.CreateCustomCharacter(1,smiley); 
LCD.CreateCustomCharacter(2,sleepy); 
LCD.CreateCustomCharacter(3,heart);
//**********************************************************************
  
   LCD.Initialize(); 
   LCD.Clear();

}



void loop() 
 {
   // Set the cursor position (note: first char is 0 not 1)
   LCD.CursorPos(0);
   LCD.PrintChar("Some Special Characters");  //according to datasheet LCD-111.pdf , p20. 
   delay(2000);
  
   LCD.Clear();
   delay(20);
   LCD.CursorPos(0);
   LCD.PrintCharx(0b10011000);   // bell
   LCD.CursorPos(2);
   LCD.PrintCharx(0b10110000);   // degree
   LCD.CursorPos(4);
   LCD.PrintCharz(0);   // Chr 1 ?
   LCD.CursorPos(6);
   LCD.PrintCharz(1);   // Chr 2 ?
   LCD.CursorPos(8);
   LCD.PrintCharz(2);   // Chr 3 ?
   LCD.CursorPos(10);
   LCD.PrintCharz(3);   // Chr 4 ?
  
   delay(4000);
   LCD.Clear();
   
 }

Anybody, any idea??

This topic was automatically closed after 120 days. New replies are no longer allowed.