hi
please find code here
https://github.com/davani1411/ws_on_off
I cannot get the placeholders to work correctly
can you help
thanks
Hi.
Can you be a little more specific?
Please describe your exact issues and any errors that you have.
Regards,
Sara
hI
please find picture of buttons
https://docs.google.com/document/d/18j7YoV7R6V4rGuseqhoqQ9WPu4fZa9kV/edit
the buttons gpio27 return the correct place holder but in the place holder for direction buttons
I think the problem is in this part of the programme
// Replaces placeholder with LED state value
String processor(const String& var) {
if(var == “STATE”) {
if(digitalRead(ledPin)) {
ledState = 1;
return “forward”;
}
else {
ledState = 0;
return “backward”;
}
}
return String();
if(var == “STATE2”) {
if(digitalRead(ledPin)) {
ledState = 1;
return “start”;
}
else {
ledState = 0;
return “stop”;
}
}
return String();
}
void notifyClients2(String state) {
ws.textAll(state);
}
void notifyClients(String state2) {
ws.textAll(state2);
}
hope this makes it clear
regards
Hi.
You have two return String() in your processor() function. Remove the first one.
You also have an issue with your javascript.
You should modify your onMessage() function to something like this:
function onMessage(event) {
var data = event.data;
if (data == "ON" || data =="OFF"){
document.getElementById('state2').innerHTML = event.data;
}
if (data == "forward" || data =="backward"){
document.getElementById('state').innerHTML = event.data;
}
console.log(event.data);
}
I hope this helps.
Regards,
Sara