Go Down

Topic: LiquidCrystal - setCursor() tutorial program correction. (Read 640 times) previous topic - next topic

aman_high

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);
     }
   }
 }

Go Up