I´m trying to wrap my head around working with text in arduino code. My current goal is to declare an array containing 8 string elements (not string objects as I´m starting to understand the drawback of these), and these elements needs to be editable but with a known max character len.
For a little background, i´m working on a menu system for an LCD and i´m sure there is a more clever way of doing this without arrays but this was a good excuse for me to learn how to use arrays. Even numbered elements will contain an attribute/effect of the text and the next (uneven) number will contain the text this will be applied to.
I´ve done extensive googeling and forum searching but it´s hard finding information on arrays containing strings but not string object. The following forum post got me going but does not explain how to properly edit the elements
http://forum.arduino.cc/index.php?topic=331337.0
This is what i have so far. It allows me to create an array and edit the first character of the elements with an ASCI number but id of course like to rewrite an entire array element without converting it to asci numbers.
Its running on an Mini Pro
#include <Arduino.h>
#include <LiquidCrystal.h>
char LcdRows[8][15]={{"blink"},{"row1"},{"scroll"},{"row2"},{""},{"row3"},{""},{"row4"}};
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup() {
Serial.begin(9600); // start serial for output
lcd.begin(20, 4 );
lcd.clear();
}
void loop() {
int LcdElement=0;
for (int i = 0; i < 4; i++){
lcd.setCursor(0, i);
lcd.print(LcdRows[LcdElement+1]);
Serial.println(LcdRows[LcdElement+1]);
LcdElement=LcdElement+2;
delay(200);
}
lcd.clear();
LcdRows[4][15]=99; //turns a row in to a cow
//Me trying to bruteforce a solution
//LcdRows[4][15]='teeest';
//LcdRows[4][15]=char('teeest');
//LcdRows[6][15]=char ("test");
//LcdRows[6][]=char ("test");
//LcdRows[6][]="test";
}