"Auto-Manual" switcher

I’d like to create a button or slider for a web page in two positions “Auto-Manual”. In “Auto” position, one part of the code will be executed. In the “Manual” position, another part of the code will be executed.
For example: if in the “Auto” position, the following will be executed:

if (temperature>=28) digitalWrite(ledPin, HIGH);
else digitalWrite(ledPin, LOW);

The code shows that, if the temperature exceeds 28 degrees, the LED will light up.
But if the button is in the manual position, then will be run another part of code, of ON-OFF buttons the of LED. Maybe there is an example or specify a link? Thank you for your help!
P.S. sorry, but Google translate, knows more than I do

What are you asking for help on?

  • How to code a switch on a web page? or
  • The logic of how to do the manual / auto thing?

I can't help with the web page part, but if it was hardware buttons on an Arduino wired to ground with INPUT_PULLUP, I'd do this (not a complete sketch, so neither compiled nor tested)

if (digitalRead(modeButton) == HIGH) //not pressed, let's say that's auto mode
{
  if (temperature >= 28)
    digitalWrite(ledPin, HIGH);
  else
    digitalWrite(ledPin, LOW);
}
else //manual mode
{
  if (digitalRead(ledButton) == HIGH) //not pressed, let's say that's led off
    digitalWrite(ledPin, LOW);
  else //pressed, on
    digitalWrite(ledPin, HIGH);
}

Forget about the Arduino for now, do you know how to code the control that you want in HTML on a Web page ?

You can do the following steps:

  • Learn how to create Web Server on Arduino
  • Creates HTML code that contains button/slider, each time button/slider changes, make GET or POST to Arduino with button/slider state.
  • When receiving the HTTP Request, Arduino get button/slider state and save it in a variable and EEPROM (just in case reboot)
  • In Arduino Loop code, you can write actions based on button/slider state variable

void-basil:

  • The logic of how to do the manual / auto thing?

Thank you very much! You're right, that's what I wanted to ask.

UKHeliBob:
Forget about the Arduino for now, do you know how to code the control that you want in HTML on a Web page ?

I've already written html and css.
I want to modernize this project.

Added this code:
if (temperature>=28) digitalWrite(ledPin, HIGH);
else digitalWrite(ledPin, LOW);
Now, at a temperature of +25 degrees, the LED lights up.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.