I have various Serial.println's throughout the sketch which get triggered at certain times. I would however like to be able to type something into the Serial interface which would return the value attributed to the mentioned variables at that given time.
Can anyone give me a quick brief on how to do this? I'm sure it wouldn't be too involved but can't find much on it.
If I understand you correctly, you will need to have some Arduino code that can receive and interpret a request from the Serial Monitor and return the appropriate value.
Try to make the request as concise as possible - perhaps an 'a' means send valueX and 'b' means send valueY. A much simpler solution might be to send all the values every time.
The variable names that you show are meaningless. At run time, there are addresses, not names. Your code needs to map a name to an address. There are no magic bullets.
Cheers Robin. From only reading the first few paragraphs I can see exactly what I need to do to get it to work. Thank you.
Paul, thats for your reply but I have no idea what you're talking about. codes? Names? addresses? Magic bullets? All I wanted was to type a letter and get a variable read back to me on the serial. Thanks anyway.
Stevelondon:
but I have no idea what you're talking about.
I suspect @PaulS thought you were asking a more complex question - that you wanted the Serial Monitor to send the name of a variable (e.g. currentColor) and for the Arduino to relate that automatically to the variable that was derived from that name by the compiler. You can do that sort of thing in an interpreted language (such as Python or Ruby) but not in a compiled language.