Delta_G:
No, you can't pass a string into digitalWrite. It expects HIGH or LOW which are actually the numbers 1 and 0. You'll need an if statement to look at your string and decide based on it if it should write HIGH or LOW to the pin. You can't just use the string directly like that.if(strcmp(someString, "Off") == 0){
digitalWrite(somePin, LOW);
else if (strcmp(someString, "On") == 0){
digitalWrite(somePin, HIGH);
}
Note, this code assumes that the only thing in the string is "On" or "Off". You have more to your string so you'll have to cut out the On or Off part to use here.
I do this and I get the same error:
void controlRelay(const char* relay, const char* state) {
if(strcmp(state, "LOW") == 0){
digitalWrite(relay, LOW);
} else if (strcmp(state, "HIGH") == 0){
digitalWrite(relay, HIGH);
}
}
Ok, so when I do digitalWrite(myPin1, LOW), the LOW or HIGH is obviously not written as an integer. It's LOW or HIGH. What is LOW or HIGH? Is this some weird aliasing going on in the background or something? You type LOW but Arduino compiles it to the integer 0?
And is myPin1 supposed to be a const char* datatype?