what am I doing wrong?
I want to use the serial monitor to recognize commands.
First I want to start a commands "A_WAARDE" to start the A_WAARDE menu. Then I want a save a variable in variable A_WAARDE for example, "3.20".
So i type "A_WAARDE" ENTER
AND "3.20" ENTER
float A_WAARDE = 0;
int ECA_WAARDE = 0;
int MAX_CMD_LENGTH = 10;
char cmd[10];
int cmdIndex;
char incomingByte;
void setup() {
// put your setup code here, to run once:
}
void loop() {
if (incomingByte=Serial.available()>0) {
char byteIn = Serial.read();
cmd[cmdIndex] = byteIn;
if(byteIn=='\n'){
//command finished
cmd[cmdIndex] = '\0';
Serial.println(cmd);
cmdIndex = 0;
//INSTELLINGEN
if (ECA_WAARDE == 1){
HELP>> A_WAARDE = cmd; //For example, "3.20"
Serial.println(A_WAARDE);
}
if(strcmp(cmd, "A_WAARDE") == 0){
ECA_WAARDE = 1;
Serial.println("ECA_WAARDE");
}
}
}
}