0

I have been working on this a while and I cannot seem to figure it out. Essentially, I am using the app/server Blynk and their Terminal Widget to sent String inputs to my Arduino board. My code is below: String INFO; String fromTerminal = param.asStr(); int indexstart = fromTerminal.indexOf(","); int indexend = fromTerminal.lastIndexOf(","); int counter = indexstart - indexend; INFO[counter] = fromTerminal;

My thoughts on the code was, based on the number of "," I enter in the string then that will assign my input to an index within the INFO array. However as I have tried several different things, I constantly get errors such as: cannot convert 'String' to 'char' in assignment. Oddly enough if I set: INFO[counter] = fromTerminal.toInt(); I dont get an error but I dont think that will allow me to print out my actual input. Any help is much appreciated, thanks!

  • INFO isn't an array - it's a String. – Majenko Jun 6 '16 at 17:45
  • Yeah so I was looking into it further, dumb oversight on my part but I guess you cant dynamically create an array. So I am just going to over initialize the array ie. INFO[20}; even when I only ever input between 5-10 strings, and then just call the index up to how many I input – Phil Jun 6 '16 at 21:55
0

I think you should better read about the String Object and don't mix this up with string as char array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.