Hello,
I have been trying to read a file from an SD card into an array. I now have this array, but it is not in the format I would like. I want it ion a char* string array. This is what I have so far:
char IRCodes[4][5];
// I want to replace the numbers with the IRcodes
// to end up with: char* irCommand[] = {"C0E8","C091","C061","C001"};
char* irCommand[] = {"0000","0001","0002","0003"};
void setup() {
IRCodes[0][0] = 'C'; // this array is what I get after I have
IRCodes[0][1] = '0'; // read the file from the SD card.
IRCodes[0][2] = 'E';
IRCodes[0][3] = '8';
IRCodes[0][4] = '\0';
IRCodes[1][0] = 'C';
IRCodes[1][1] = '0';
IRCodes[1][2] = '9';
IRCodes[1][3] = '1';
IRCodes[1][4] = '\0';
IRCodes[2][0] = 'C';
IRCodes[2][1] = '0';
IRCodes[2][2] = '6';
IRCodes[2][3] = '1';
IRCodes[2][4] = '\0';
IRCodes[3][0] = 'C';
IRCodes[3][1] = '0';
IRCodes[3][2] = '0';
IRCodes[3][3] = '1';
IRCodes[3][4] = '\0';
Serial.begin(19200);
char* strCmd;
int cc = 0;
for (int i=0; i < 4; i++) {
Serial.print(i);
Serial.print(". ");
strCmd = "";
for (int ii = 0; ii < 5; ii++) {
Serial.print(IRCodes[i][ii]);
strCmd += IRCodes[i][ii]; // does not work
}
Serial.print("\n");
Serial.println(strCmd);
irCommand[i] = strCmd;
}
Serial.println("-----------");
for (int i=0; i < 4; i++) {
Serial.print(i);
Serial.print(". ");
Serial.println(irCommand[i]);
}
}
void loop()
{
// nothing happens after setup
}
as you can see, the variable strCmd is not picking up the element from IRcodes.
Can you help?
Thanks
Karl.