LCD Function for typewriter like typing.. HELP

Hi guys i want to write the welcoming message like a typewriter , i mean a delay between each char.
like this code

 lcd.print('H'); delay(10); lcd.print('e');delay(10); lcd.print('l');delay(10); lcd.print('l'); delay(10);lcd.print('o');delay(10);

i started to make my own function but i failed

void writer (char input[16] ) { 
  for (int i = 1; i <= 16; i++) {
   lcd.print( input[i]);
  }
  }

please help :frowning:

C arrays have zero-origin indexing, and so a sixteen element array has no index sixteen

you can try like this...

void typeWriter(char* text);

void setup() 
{
  Serial.begin(9600);
  Serial.println();
  typeWriter("Greetings from Arduino");
  Serial.println();
  typeWriter("Take Me To Your Leader");
  Serial.println();
}

void loop() 
{

}

void typeWriter(char* text)
{
  while(text[0])
  {
    Serial.write(text++[0]);
    delay(100);
  }
}

Your code is heading in the right direction...

void writer (char *message) { 
  char *msgptr = &message;
  while (*msgptr) {
   lcd.write(*msgptr++);
   delay(20);  
  }
}

delay() is ok in this example, but if it was within a main loop(), you may prefer to call the writer function with millis() - so that nothing else is held up by the delay() calls.

NOT DOUBLE-CHECKED or TESTED, but the idea is there, and the code can be shortened once you understand how it works. You could also pass the interval as a second parameter in the function header. e.g.

void writer(char *message, char interval) { }

@lastchancename Why would you take the address of message. Message is already a pointer and you're taking the address where pointer is stored.

Change

  char *msgptr = &message;

to

  char *msgptr = message;

sterretje:
@lastchancename
Why would you take the address of message.

Why do you even need a copy of the pointer that was already passed?

reply #2

1 typo

2 I wanted to expand the example for OP to start using pointers

thanks for catching #1