Is have some code that reads code from my serial port (PC). using a boolean I want to be able to enable/disable printing of the read input back to my PC (it should be disabled default)
On top of my sketch I've declared:
//GamePadSerialFeedback variables declaration
boolean GamepadSerialFeedback = false;
const char SerialFeedbackOn[] = "~SerialFeedbackOn#";
const char SerialFeedbackOff[] = "~SerialFeedbackOff#";
After reading the serial code (the code has to include the following header and footer) the input is saved inside an array (StringIn):
Header: ~
Footer: #
based on a certain command the printing function is enabled or disabled:
//Enables or disables the feedback (print) from the arduino to the interface software.
if (strcmp(SerialFeedbackOff,StringIn) == 0){
Serial.print("~GamepadSerialFeedbackOff#");
GamepadSerialFeedback = false;
}
else if (strcmp(SerialFeedbackOn,StringIn) == 0){
Serial.print("~GamepadSerialFeedbackOn#");
GamepadSerialFeedback = true;
}
if (GamepadSerialFeedback == true){
// Print the array. Debugging code
for(int j=0; j < (i-1) ; j++){
Serial.print(StringIn[j]);
}
}
But the GamepadSerialFeedback variable is not changed and keeps the value as declared ont top of my sketch?
Is it not possible to change the state/value of a variable at runtime?
Thanks in advance,
Cheers /me