#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte pattern[][8] =
{
{
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
},
{
0b00100,
0b01000,
0b01000,
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
},
{
0b00001,
0b00010,
0b00110,
0b00100,
0b01000,
0b01000,
0b10000,
0b10000,
},
{
0b10000,
0b01000,
0b01100,
0b00100,
0b00010,
0b00010,
0b00001,
0b00001,
},
{
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00001,
0b00011,
},
{
0b00000,
0b00000,
0b00000,
0b00000,
0b00100,
0b11111,
0b00000,
0b00000,
},
{
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b10000,
0b11000,
},
{
0b00100,
0b00010,
0b00010,
0b00001,
0b00001,
0b00001,
0b00001,
0b00001,
},
{
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
0b01000,
0b01000,
0b00100,
},
{
0b00011,
0b00011,
0b00001,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
},
{
0b00000,
0b00000,
0b00000,
0b11111,
0b00100,
0b00000,
0b00000,
0b00000,
},
{
0b11000,
0b11000,
0b10000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
},
{
0b00001,
0b00001,
0b00001,
0b00001,
0b00001,
0b00010,
0b00010,
0b00100,
},
};
void setup()
{
lcd.begin(16,2);
lcd.clear();
}
void loop()
{
// ==========================================================
// Show custom pattern of top row
// ==========================================================
lcd.clear();
delay( 500);
lcd.createChar(0, pattern[0]);
lcd.createChar(1, pattern[1]);
lcd.createChar(2, pattern[2]);
lcd.createChar(3, pattern[3]);
lcd.createChar(4, pattern[4]);
lcd.createChar(5, pattern[5]);
lcd.createChar(6, pattern[6]);
lcd.createChar(7, pattern[7]);
// The character with value zero can not be printed with a zero-terminated string.
lcd.setCursor(2, 0);
lcd.write('\0');
lcd.setCursor(12, 0);
lcd.write('\0');
lcd.setCursor(3,0);
lcd.write( "\1\2\3\4\5\6\2\3\7");
delay( 2000);
// ==========================================================
// Show custom pattern of bottom row
// ==========================================================
lcd.clear();
delay( 500);
lcd.createChar(1, pattern[8]);
lcd.createChar(2, pattern[9]);
lcd.createChar(3, pattern[10]);
lcd.createChar(4, pattern[11]);
lcd.createChar(5, pattern[12]);
lcd.setCursor(3,1);
lcd.write( "\1 \2\3\4 \5");
delay( 2000);
// ==========================================================
// Show all the patterns from the array
// ==========================================================
lcd.clear();
delay( 500);
lcd.setCursor( 0, 0);
lcd.write( "Index : ");
lcd.setCursor( 0, 1);
lcd.write( "Custom : \7");
for( int i=0; i<sizeof( pattern)/sizeof(pattern[0]); i++)
{
lcd.setCursor( 9, 0);
lcd.print( i);
lcd.createChar(7, pattern[i]);
delay( 500);
}
delay( 1000);
}