Hi
Could someone please help me in declaring a global text variable. So the variable can be changed with different text information within a given subroutine see example below for the concept of my objective.
I tried char FA[20];
Placed above void setup
With
void loop(){
FA = “In Loop”
SubOne;
SubTwo;
Rest of code
void subOne
FA = “subOne”
Rest of code
void subTwo
FA = “subTwo”
Rest of code
Using the above concept I get the following error from Arduino IDE 2.3.7
Incompatible types in assignment of ‘const char [14]’ to ‘char [20]’
I would very much appreciate if somebody could point me in the correct direction to achieve my objective.
Hi.
The easiest way to solve this issue is to declare your FA variable as a String.
String FA;
If you really want to use a const char, you need to understand that with char FA[20] you’re creating a fixed memory buffer, and to assign something to it, you must copy the text into it using the strcpy() function. You can learn more here: https://www.geeksforgeeks.org/c/strcpy-in-c/
I hope this helps.
Regards,
Sara