Go Down

Topic: Why this sketch is not working? (Read 306 times) previous topic - next topic

Lavan

Hi There!  I want to scroll the text on the LCD.  I am using the below sketch but its giving error "cannot convert 'String' to 'char*' for argument '1' to 'void marquee(char*)". What I have to do to get this worked?

Thanks.

Code: [Select]
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int numRows = 2;
const int numCols = 16;
String stringOne;
String stringTwo;
String stringThree;
void setup()
{
  // set up the LCD's number of columns and rows:
  lcd.begin(numCols, numRows);
}
void loop()
{

  stringOne = "HELLO WORLD!!";
  stringTwo = "hello world!!";
  stringThree = stringOne + stringTwo;
  marquee(stringThree);
  delay(1000);
  lcd.clear();
}

// this function uses scrolling to display a message up to 32 bytes long
void marquee(char  *text )
{
  int length = strlen(text); // the number of characters in the text
  if(length < numCols)
    lcd.print(text);
  else
  {
    int pos;
    for( pos = 0; pos < numCols; pos++)
      lcd.print(text[pos]);
    delay(1000); // allow time to read the first line before scrolling
    while(pos < length)
    {
      lcd.scrollDisplayLeft();
      lcd.print(text[pos]);
      pos = pos + 1;
      delay(300);
    }
  }
}

AWOL

#1
Jun 07, 2013, 03:37 pm Last Edit: Jun 07, 2013, 03:40 pm by AWOL Reason: 1
Stop using String, and use char arrays instead.

(please don't say the sketch isn't working - to decide on working/not working, the code has to compile and run.)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up