Pages: [1]   Go Down
Author Topic: LiquidCrystal - setCursor() tutorial program correction.  (Read 523 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tutorial example available at http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor
has a small problem. In loop function variable names are wrong.

1) thisCol Should be thisRow
2) thisRow Should be thisCol

Its working fine since he compared thisRow to numCols and thiscol to numRows but naming is wrong.
It has no impact on working but confuses reader.

  for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
    for (int thisCol = 0; thisCol < numRows; thisCol++) {
      for (int thisRow = 0; thisRow < numCols; thisRow++) {
        lcd.setCursor(thisRow,thisCol);
        lcd.write(thisLetter);
        delay(200);
      }
    }

Correct loops are

void loop() {
  // loop from ASCII 'a' to ASCII 'z':
  for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
    // loop over the columns:
    for (int thisRow = 0; thisRow < numRows; thisRow++) {
      // loop over the rows:
      for (int thisCol = 2; thisCol < numCols; thisCol++) {
        // set the cursor position:
        lcd.setCursor(thisCol,thisRow);
        // print the letter:
        lcd.write(thisLetter);
        delay(200);
      }
    }
  }
Logged

Pages: [1]   Go Up
Jump to: