arduino:displays_for_classic_arduinos:display_character_20x4_counter.ino
This is an old revision of the document!
- display_character_20x4_counter.ino
/* display_character_20x4_counter.ino Mithat Konar Test screen update speed with "BIG" fonts on a 20x4 character display using a parallel interface. Notes: Consumes 15% of program storage space and 6% of dynamic memory on a Nano. */ /* Pin assignments (unlisted pins are note connected): VSS: ground VDD: 5VDC V0: wiper of contrast potentiometer RS: 12 RW: pullup to Vcc EN: 11 D4: 5 D5: 4 D6: 3 D7: 2 LED cathode: 5VDC through dropping resistor (47 ohm). LED anode : ground */ #include <BigCrystal.h> #include <LiquidCrystal.h> const unsigned int RS_PIN = 12, ENABLE_PIN = 11, D4_PIN = 5, D5_PIN = 4, D6_PIN = 3, D7_PIN = 2; LiquidCrystal lcd(RS_PIN, ENABLE_PIN, D4_PIN, D5_PIN, D6_PIN, D7_PIN); BigCrystal bigCrystal(&lcd); unsigned int now, then = 0; // used to track time unsigned counter = 80; char dispStr[4]; // null terminated char array used to pass to renderer. const unsigned int LOOP_DELAY = 500; // msec of additional loop delay void setup(void) { bigCrystal.begin(20, 4); bigCrystal.print("20x4 char (parallel)"); // print legend(s) bigCrystal.setCursor(0, 1); bigCrystal.print("Render time:"); } void loop(void) { then = now; now = millis(); // print render time bigCrystal.setCursor(13, 1); // clear the old data bigCrystal.print(" "); bigCrystal.setCursor(13, 1); // print new data bigCrystal.print(now - then - LOOP_DELAY); bigCrystal.setCursor(16, 1); // print units bigCrystal.print("msec"); // print a big counter counter = (counter + 1 ) % 1000; String(counter).toCharArray(dispStr, 4); bigCrystal.printBig(dispStr, 0, 2); /* Render time with a 16 MHz processor is around * 14 msec, independent of LOOP_DELAY but dependent on * the number of characters being drawn. */ delay(LOOP_DELAY); }
arduino/displays_for_classic_arduinos/display_character_20x4_counter.ino.1517265186.txt.gz · Last modified: 2018/01/29 22:33 by mithat