Skip to content

Commit

Permalink
Improved example
Browse files Browse the repository at this point in the history
  • Loading branch information
davetcc committed Apr 15, 2020
1 parent d2a0ad1 commit 405b898
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions examples/Counter23017/Counter23017.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const int lcdWidth = 20;
// now construct the display using IO from a 23017
LiquidCrystal lcd(rs, en, d4, d5, d6, d7, ioFrom23017(0x20));

byte smiley[8] = {
const byte smiley[8] PROGMEM = {
0b00000,
0b00000,
0b01010,
Expand Down Expand Up @@ -61,7 +61,7 @@ void setup() {

// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
lcd.createChar(1, smiley);
lcd.createCharPgm(1, smiley);
lcd.setCursor(0,0);
lcd.print("Counter in seconds");

Expand All @@ -76,17 +76,20 @@ void setup() {
// set the cursor to column 0, line 1
lcd.setCursor(0, 1);

// print the number of seconds since reset in tenths as a float:
float fractionalMillis = millis() / 100.0f;
// print the number of seconds since reset as a float:
float fractionalMillis = millis() / 1000.0f;
lcd.print(fractionalMillis);

// now we move our custom character across the screen, clear the last place as we go.
// now in row 2 we move our custom character across the screen
// by first clearing the last position
lcd.setCursor(oldPos,2);
lcd.print(' ');

// find the next position (reset to 0 if need be)
oldPos++;
if(oldPos == lcdWidth) oldPos = 0;

// then print the character
lcd.setCursor(oldPos,2);
lcd.write(0x01);
});
Expand Down

0 comments on commit 405b898

Please sign in to comment.