Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
    
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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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