Hello together
I am new to this forum as well as dealing with arduino and programming languages. If I do something wrong please tell me. Thanks for your help.
Edit: The post was temporarily locked. I am sorry if I am doing something wrong or have expressed myself incorrectly. Please just tell me what to change, as I said I am new to this forum.
So I'm trying to control three leds with the ESP32 NodeMCU developer board. I want to control the brightness of two of them independently with a potentiometer. And the red one I want to switch on and off with a simple button press.
So far so good. I have been inspired on the internet and tinkered a code with which these functions work properly. (code is attached)
Now to my question / problem:
I would like to be able to control the same function via smartphone or Pc in the home Wifi. I do not need a web overlay, a simple URL which executes the commands would be enough.
I found these two projects which show a similar functionality to how I want it to work:
The first one would be great to control the red LED and the second one would be perfect to control the brightness of the two yellow ones with HTTP requests.
But I have not managed to combine these two, as well as to create two sliders. I think it would be very easy, but as I said I am new to all this.
Also, I haven't figured out how to run the old code (pasted below) at the same time to control everything physically.
I am glad for any help. Thanks a lot!
My old code:
#include <analogWrite.h>
#define LED1 5
#define LED2 18
#define LED3 19
#define BUTTON 23
#define POTI1 35
#define POTI2 13
int LED1VALUE = 150;
int LED2VALUE = 150;
int BUTTONSTATE;
int LED3STATE = 0;
boolean lastBUTTONSTATE = LOW;
void setup() //setup Code
{
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(POTI1, INPUT);
pinMode(POTI2, INPUT);
pinMode(BUTTON, INPUT_PULLUP);
}
void loop()
{
BUTTONSTATE = digitalRead(BUTTON);
if (BUTTONSTATE != lastBUTTONSTATE) {
lastBUTTONSTATE = BUTTONSTATE;
if (BUTTONSTATE == LOW) {
LED3STATE = (LED3STATE == HIGH) ? LOW: HIGH;
digitalWrite(LED3, LED3STATE);}}
int potentiometerValue1 = analogRead(POTI1);
LED1VALUE = potentiometerValue1 / 16.06;
analogWrite(LED1, LED1VALUE);
int potentiometerValue2 = analogRead(POTI2);
LED2VALUE = potentiometerValue2 / 16.06;
analogWrite(LED2, LED2VALUE);
}
My setup: