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
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);
}
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.