Go Down

Topic: Error in setCursor example (LiquidCrystal library) (Read 708 times) previous topic - next topic

Johan Alink

The setCursor example is confusing and therefore wrong (examples are there to clarify things, not to confuse  ;) )

In the example (both on the website and in the v0017 download) the setCursor is used as:
Code: [Select]
The Reference says the syntax of setCursor is:
Code: [Select]
lcd.setCursor(col, row)
So the example uses different order for column and row parameters :-/

Also the for-next loops are confusing, thisCol counts from 0 to numRows:
Code: [Select]
for (int thisCol = 0; thisCol < numRows; thisCol++) {

and thisRow counts from 0 to numCols:
Code: [Select]
for (int this[b]Row[/b] = 0; thisRow < numCols; thisRow++) {

To clear up things I would suggest the following changes:
Code: [Select]
    // loop over the rows:
    for (int thisRow= 0; thisRow < numRows; thisRow++) {
      // loop over the columns:
      for (int thisCol = 0; thisCol < numCols; thisCol++) {
        // set the cursor position:


An oversight, we changed the order of the parameters, but not the naming, I'll get that cleaned up for the next version

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131