user46009: I'm trying to write web server code. However, I am having trouble with part of it.
Currently, to get it to save a bool variable I have it use a pin, as when I ran the code without it, after the page refreshes it resets the variable to its original value.
How do I get it to save the variable in this code without it using the pin?
digitalWrite (equalPin, server.arg("equal").toInt());
char equalText[80];
if(equalState) {
  strcpy(equalText, "priority is equal. <a href=\"/?equal=0\">Deactivate</a>");
  equalState = false;
} else {
  strcpy(equalText, "priority is not equal. <a href=\"/?equal=1\">Activate</a>");
  equalState = true;
}
equalState = digitalRead(equalPin);

I also have several over copies of this for different pages but if I change 1 of them they all change and reset after 10 seconds.
The code follows the example on this site.

user37622: same code snippet without using pin
char equalText[80];

if (equalState){
  strcpy(equalText, "priority is equal. <a href=\"/?equal=0\">Deactivate</a>");
  equalState = false;
}
else {
  strcpy(equalText, "priority is not equal. <a href=\"/?equal=1\">Activate</a>");
  equalState = true;
}
equalState = server.arg("equal").toInt();

but it does not make much sense to set the value if you already switched the state based on it's previous value

46009: <p>I'm trying to write web server code. However, I am having trouble with part of it.</p>

<p>Currently, to get it to save a bool variable I have it use a pin, as when I ran the code without it, after the page refreshes it resets the variable to its original value.</p>

<p>How do I get it to save the variable in this code without it using the pin?</p>

<pre><code>digitalWrite (equalPin, server.arg("equal").toInt());
char equalText[80];
if(equalState) {
  strcpy(equalText, "priority is equal. &lt;a href=\"/?equal=0\"&gt;Deactivate&lt;/a&gt;");
  equalState = false;
} else {
  strcpy(equalText, "priority is not equal. &lt;a href=\"/?equal=1\"&gt;Activate&lt;/a&gt;");
  equalState = true;
}
equalState = digitalRead(equalPin);
</code></pre>

<p>I also have several over copies of this for different pages but if I change 1 of them they all change and reset after 10 seconds.</p>

<p>The code follows the example on <a href="https://42bots.com/tutorials/esp8266-example-wi-fi-access-point-web-server-static-ip-remote-control/" rel="nofollow noreferrer">this site</a>.</p>
 37622: <p>same code snippet without using pin</p>

<pre><code>char equalText[80];

if (equalState){
  strcpy(equalText, "priority is equal. &lt;a href=\"/?equal=0\"&gt;Deactivate&lt;/a&gt;");
  equalState = false;
}
else {
  strcpy(equalText, "priority is not equal. &lt;a href=\"/?equal=1\"&gt;Activate&lt;/a&gt;");
  equalState = true;
}
equalState = server.arg("equal").toInt();
</code></pre>

<p>but it does not make much sense to set the value if you already switched the state based on it's previous value</p>
