J'ai fait exactement ça pour le TouchPad midi. Voici le code uniquement pour le LCD :
#define LCD_RS 8 // Register select
#define LCD_EN 9 // Enable
#define LCD_D4 10 // Data bits
#define LCD_D5 11 // Data bits
#define LCD_D6 12 // Data bits
#define LCD_D7 13 // Data bits
/**********************************************************************
*
* LCD
* Based on 4bit interface example
* 2006 Massimo Banzi
* Based on code written by Craig Lee 1998
* 2007 Ludovic Drochon : LCDbar127
*
**********************************************************************/
void lcd_strobe()
{
digitalWrite(LCD_EN,HIGH);
digitalWrite(LCD_EN,LOW);
}
/* write a byte to the LCD in 4 bit mode */
void lcd_write(byte c)
{
if(c & 0x80) digitalWrite(LCD_D7,HIGH); else digitalWrite(LCD_D7,LOW);
if(c & 0x40) digitalWrite(LCD_D6,HIGH); else digitalWrite(LCD_D6,LOW);
if(c & 0x20) digitalWrite(LCD_D5,HIGH); else digitalWrite(LCD_D5,LOW);
if(c & 0x10) digitalWrite(LCD_D4,HIGH); else digitalWrite(LCD_D4,LOW);
lcd_strobe();
if(c & 0x08) digitalWrite(LCD_D7,HIGH); else digitalWrite(LCD_D7,LOW);
if(c & 0x04) digitalWrite(LCD_D6,HIGH); else digitalWrite(LCD_D6,LOW);
if(c & 0x02) digitalWrite(LCD_D5,HIGH); else digitalWrite(LCD_D5,LOW);
if(c & 0x01) digitalWrite(LCD_D4,HIGH); else digitalWrite(LCD_D4,LOW);
lcd_strobe();
delayMicroseconds(40);
}
/*
* Clear and home the LCD
*/
void lcd_clear(void)
{
digitalWrite(LCD_RS,LOW);
lcd_write(0x1);
delay(2);
}
/* write a string of chars to the LCD */
void lcd_puts(const char * s)
{
digitalWrite(LCD_RS,HIGH); // write characters
while(*s) lcd_write(*s++);
}
/* write one character to the LCD */
void lcd_putch(byte c)
{
digitalWrite(LCD_RS,HIGH); // write characters
lcd_write(c);
}
/*
* Go to the specified position
*/
void
lcd_goto(byte pos)
{
digitalWrite(LCD_RS,0);
lcd_write(0x80 + pos);
}
/* initialise the LCD - put into 4 bit mode */
void
lcd_init(void)
{
pinMode(LCD_D7,OUTPUT);
pinMode(LCD_D6,OUTPUT);
pinMode(LCD_D5,OUTPUT);
pinMode(LCD_D4,OUTPUT);
pinMode(LCD_EN,OUTPUT);
pinMode(LCD_RS,OUTPUT);
digitalWrite(LCD_RS, LOW); // write control bytes
delay(15);// power on delay
digitalWrite(LCD_D4, HIGH); // init!
digitalWrite(LCD_D5, HIGH); //
lcd_strobe();
delay(5);
lcd_strobe();// init!
delayMicroseconds(100);
lcd_strobe();// init!
delay(5);
digitalWrite(LCD_D4, LOW); // set 4 bit mode
lcd_strobe();
delayMicroseconds(40);
lcd_write(0x28);// 4 bit mode, 1/16 duty, 5x8 font, 2lines
lcd_write(0x0C);// display on
lcd_write(0x06);// entry mode advance cursor
lcd_write(0x01);// clear display and reset cursor
}
void downloadcustomcharacter(int CGRAMaddress, byte character[])
{
for (int i = 0; i<8; i++) //load character bytes in to CGRAM
{
lcd_putch(character[i]);
}
delay(20);
}
void setup() {
delay (20);
lcd_init();
delay (200);
lcd_write(0x40);
//delay(40);
byte barre1[] = {0x00,0x1F,0x00,0x00,0x00,0x00,0x1F,0x00}; //progress bar characters
byte barre2[] = {0x00,0x1F,0x10,0x10,0x10,0x10,0x1F,0x00};
byte barre3[] = {0x00,0x1F,0x18,0x18,0x18,0x18,0x1F,0x00};
byte barre4[] = {0x00,0x1F,0x1C,0x1C,0x1C,0x1C,0x1F,0x00};
byte barre5[] = {0x00,0x1F,0x1E,0x1E,0x1E,0x1E,0x1F,0x00};
byte barre6[] = {0x00,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x00};
downloadcustomcharacter (0 , barre1);
downloadcustomcharacter (1 , barre2);
downloadcustomcharacter (2 , barre3);
downloadcustomcharacter (3 , barre4);
downloadcustomcharacter (4 , barre5);
downloadcustomcharacter (5 , barre6);
}
void loop() {
}