i have an if statement but when i try and compile it saying
ISO C++ forbids comparison between pointer and integer [-fpermissive]
Here is the code i am trying to watch for a button press on an RF button and will transmit a simple message
a--BUTTONA
char command = Serial.read();
if (command == ("a--BUTTONA")) {
digitalWrite(ledred, HIGH);
}
else {}
Based on that snippet of code, command will only hold a single character. So trying to compare it to a String is a waste of time.
dannable:
Based on that snippet of code, command will only hold a single character. So trying to compare it to a String is a waste of time.
so what would be a solution to this??
im still new to all this
and nick thanks for the input i have seen the link but im confused in what you want me to see
char command = Serial.read();
if (command == ("a")) {
digitalWrite(ledred, HIGH);
}
else {}
still get the same
Make 'command' an array of char. As you read Serial put each new character into the next position in the array. When you have received all the characters then you can do your compare.
Try single quotes - 'a'.
This question seems to come up all the time. Have a read of Robins "Planning and Implementing an Arduino Program" thread, its a sticky at the top of the programming forum board. Particularly this chapter:
CHAPTER 8 - RESPONSE FROM USER
Serial tutorial