First am very sorry for annoying you everytime with my noob messages,
Second very big thank you for your real support
Third i finally succeeded after some searches to make it work fine with zeRGBa
here the code worked for me
if you see something can be improved please let me know if possible
i was wondering if i can put 1 button to make the RGB totally on or off, then if it is on, so i can control the colors through zeRGBa, i will search for this i think it is possible and i will try it.
regarding the IRLB8721 if i understand correctly, i will use three MOSFETs and connect their 3 gates with three PWM GPIO of the ESP32 for the control of 12V RGB Strip light (and accordingly drains connected to the led and source connected to negative of the 12V supply), the wiring is ok like this i think
i really appreciate so much your help, do not know what i would do without your help.
#define BLYNK_PRINT Serial
//#define BLYNK_PRINT Serial // This prints to Serial Monitor
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <ESPmDNS.h> // For OTA - ESP32
#include <WiFiUdp.h> // For OTA
#include <ArduinoOTA.h> // For OTA
#include "esp32-hal-ledc.h" // For Servo & RGB PWM control
char auth[] = "*******";
char ssid[] = "Ayman33";
char pass[] = "braveheart333";
char server[] = "blynk-cloud.com"; // URL for Blynk Cloud Server
int port = 8080;
int rrr, ggg, bbb; // Set RED BLUE GREEN channe
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
//Serial.begin(115200); // BLYNK_PRINT data
//===== RGB LED pin setup for ESP32 =====
ledcSetup(2, 5000, 8); // For RGB-Red - channel 2, 5000 Hz, 8-bit width
ledcAttachPin(25, 2); // For RGB-Red - GPIO 25 assigned to channel 2
ledcSetup(3, 5000, 8); // For RGB-Green - channel 3, 5000 Hz, 8-bit width
ledcAttachPin(27, 3); // For RGB-Green - GPIO 27 assigned to channel 3
ledcSetup(4, 5000, 8); // For RGB-Blue - channel 4, 5000 Hz, 8-bit width
ledcAttachPin(26, 4); // For RGB-Blue - GPIO 26 assigned to channel 4
WiFi.begin(ssid, pass);
Blynk.config(auth, server, port);
Blynk.connect();
ArduinoOTA.setHostname("ESP32 Servo RGB"); // For OTA - Use your own device identifying name
ArduinoOTA.begin(); // For OTA
}
//===== zeRGBa Widget =====
BLYNK_WRITE(V4) { // START Blynk Function
rrr = param[0].asInt(); // get a RED channel value
ggg = param[1].asInt(); // get a GREEN channel value
bbb = param[2].asInt(); // get a BLUE channel value
RGBprocess(); // Run Arduino funtion
} // END Blynk Function
//===== Physical RGB LED Control and HEX conversion =====
void RGBprocess() { // START Arduino funtion
// For Common Anode+ RGB LED
//ledcWrite(2, 256 - rrr); // Write to RED RGB pin
// ledcWrite(3, 256 - ggg); // Write to GREEN RGB pin
//ledcWrite(4, 256 - bbb); // Write to BLUE RGB pin
// For Common Cathode- RGB LED
ledcWrite(2, rrr); // Write to RED RGB pin
ledcWrite(3, ggg); // Write to GREEN RGB pin
ledcWrite(4, bbb); // Write to BLUE RGB pin
// zeRGBa pin to #HEX conversion
String strRED = String(rrr, HEX); // Convert RED DEC to HEX
if (rrr < 16) {
strRED = String("0" + strRED); // Buffer with 0 if required
} // END if
String strGRN = String(ggg, HEX); // Convert GREEN DEC to HEX
if (ggg < 16) {
strGRN = String("0" + strGRN); // Buffer with 0 if required
} // END if
String strBLU = String(bbb, HEX); // Convert BLUE DEC to HEX
if (bbb < 16) {
strBLU = String("0" + strBLU); // Buffer with 0 if required
} // END if
String HEXstring = String("#" + strRED + strGRN + strBLU); // Combine HEX fragments
HEXstring.toUpperCase(); // Change HEX value to all upper case for ease of visuals.
Blynk.setProperty(V3, "color", HEXstring); // Change background colour of HEX Data Label
Blynk.virtualWrite(V3, HEXstring); // Display HEX data
} // END Arduino Function
void loop()
{
Blynk.run();
ArduinoOTA.handle(); // For OTA
timer.run(); // Initiates BlynkTimer
}