Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // include the library code:
- #include <LiquidCrystal.h>
- // initialize the library with the numbers of the interface pins
- LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
- #define UP 2
- #define DOWN 3
- unsigned int counter = 0;
- //************************************************************************
- //* A set of custom made large numbers for a 16x2 LCD using the
- //* LiquidCrystal librabry. Works with displays compatible with the
- //* Hitachi HD44780 driver.
- //* LT= left top
- //* UB= upper bar
- //* RT= right top
- //* LL= lower left
- //* LB= lower bar
- //* LR= lower right
- //* UMB= upper middle bars(upper middle section of the '8')
- //* LMB= lower middle bars(lower middle section of the '8')
- const uint8_t gBigFontShapeTable[] PROGMEM = {
- B00111, B01111, B11111, B11111, B11111, B11111, B11111, B11111, // LT[8]
- B11111, B11111, B11111, B00000, B00000, B00000, B00000, B00000, // UB[8]
- B11100, B11110, B11111, B11111, B11111, B11111, B11111, B11111, // RT[8]
- B11111, B11111, B11111, B11111, B11111, B11111, B01111, B00111, // LL[8]
- B00000, B00000, B00000, B00000, B00000, B11111, B11111, B11111, // LB[8]
- B11111, B11111, B11111, B11111, B11111, B11111, B11110, B11100, // LR[8]
- B11111, B11111, B11111, B00000, B00000, B00000, B11111, B11111, // UMB[8]
- B00000, B00000, B00000, B00000, B00000, B11111, B11111, B11111 // LMB[8]
- };
- //* 6 numbers for each character
- const uint8_t gBigFontAsciiTable[] PROGMEM = {
- 0, 1, 2, 3, 4, 5, // 0x30 0
- 1, 2, 32, 4, 5, 4, // 0x31 1
- 6, 6, 2, 3, 7, 7, // 0x32 2
- 1, 6, 2, 7, 7, 5, // 0x33 3
- 3, 4, 2, 32, 32, 5, // 0x34 4
- 0, 6, 6, 7, 7, 5, // 0x35 5
- 0, 6, 6, 3, 7, 5, // 0x36 6
- 1, 1, 2, 32, 0, 32, // 0x37 7
- 0, 6, 2, 3, 7, 5, // 0x38 8
- 0, 6, 2, 32, 32, 5 // 0x39 9
- };
- //************************************************************************
- void BigNumber_SendCustomChars(void){
- uint8_t customCharDef[10];
- uint8_t ii, jj;
- for (ii=0; ii<8; ii++) {
- for (jj=0; jj<8; jj++) {
- customCharDef[jj] = pgm_read_byte_near(gBigFontShapeTable + (ii * 8) + jj);
- }
- lcd.createChar(ii, customCharDef);
- }
- }
- //************************************************************************
- void DrawBigChar(int xLocation, int yLocation, char theChar){
- int offset, ii;
- char theByte;
- offset = 6 * (theChar - 0x30);
- lcd.setCursor(xLocation, yLocation);
- for (ii=0; ii<3; ii++) {
- theByte = pgm_read_byte_near(gBigFontAsciiTable + offset + ii);
- lcd.write(theByte);
- }
- lcd.setCursor(xLocation, yLocation + 1);
- offset += 3;
- for (ii=0; ii<3; ii++) {
- theByte = pgm_read_byte_near(gBigFontAsciiTable + offset + ii);
- lcd.write(theByte);
- }
- }
- void setup() {
- Serial.begin(9600);
- pinMode(UP, INPUT_PULLUP);
- pinMode(DOWN, INPUT_PULLUP);
- lcd.begin(16, 2);
- lcd.print("Start...");
- delay(1000);
- lcd.clear();
- BigNumber_SendCustomChars();
- }
- void loop() {
- Serial.print(F("Counter value : "));
- Serial.println(counter);
- DrawBigChar(4, 0, 0x30+counter);
- DrawBigChar(8, 0, 0x30+counter);
- counter = (++counter) % 10;
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement