Time İnput and ZeRGBa (DS1302)

Hello to everyone. I just started using blynk. My goal is to make a time-controlled RGB LED controller. What I use for this job:

  • Android phone
  • Arduino Mega
  • Rtc module Ds1302
  • Esp 8266 (esp-01)

Virtual pin :
V2: Zergba
V3: Zergba
V4: Zergba
V5: Time input
V6: Time input
V7: Time input
Each time input is connected to a zergba. user will enter time information. When the arduino, ds1302 and time input values ​​are equal, if the start time has come, the rgb led will light in the specified color (zergba),when the stop time comes, the rgb led will turn off.

I couldn’t do it because I’m new, but I studied many projects, videos and articles. But I couldn’t run it. Can you help me please?
Code:


> #define     BLYNK_PRINT Serial
> #include <ESP8266WiFi.h>
> #include <BlynkSimpleEsp8266_SSL.h>
> #include <DS1302>
> 
> 
> // You should get Auth Token in the Blynk App.
> // Go to the Project Settings (nut icon).
> char auth[] = "YourAuthToken";
> 
> DS1302 rtc(2,3,4); 
> Time t;
> 
> BLYNK_CONNECTED() {
>    Blynk.syncAll();
>  // Synchronize time on connection
> 
> 
> void setup()
> {
> rtc.writeProtect(false);
>  Serial.begin(115200);
>  rtc.setDOW(SUNDAY);      // Set Day-of-Week 
>  rtc.setTime(22, 12, 35);   // Set the time to 12:00:00 (24hr format)
>  rtc.setDate(2, 8, 2020); // tarih 
>   
> }
>   // Debug console
>   Serial.begin(115200);
> 
>   Blynk.begin(auth);
> 
> }
> 
> 
> BLYNK_WRITE(V5) {  
>   TimeInputParam t(param);
> }
> 
>   if ((t.hour == RemoteXY.edit_s && t.min == RemoteXY.edit_d))
>   {
>     Serial.println(String("Start: ") +
>                    t.getStartHour() + ":" +
>                    t.getStartMinute() + ":" +
>                    t.getStartSecond());
> BLYNK_WRITE(V2)
> {   
>   redValue = param[0].asInt();
>   greenValue = param[1].asInt();
>   blueValue = param[2].asInt();
> 
>   analogWrite(RED_PIN, redValue);
>   analogWrite(GREEN_PIN, greenValue);
>   analogWrite(BLUE_PIN, blueValue);
> 
> }
> 
>    }
>    
>    if ((t.hour == RemoteXY.edit_s && t.min == RemoteXY.edit_d)
>   {
>     Serial.println(String("Stop: ") +
>                    t.getStopHour() + ":" +
>                    t.getStopMinute() + ":" +
>                    t.getStopSecond());
> BLYNK_WRITE(V2)
> {   
>   redValue = param[0].asInt();
>   greenValue = param[1].asInt();
>   blueValue = param[2].asInt();
> 
>   analogWrite(RED_PIN, redValue*0);
>   analogWrite(GREEN_PIN, greenValue*0);
>   analogWrite(BLUE_PIN, blueValue*0);
> 
> }
> 
>   }
> 
> // 1. time input
> 
>   BLYNK_WRITE(V6) {  
>   TimeInputParam t(param);
> }
> 
>   if ((t.hour == t.getStartHour() && t.min == t.getStartMinute())
>   {
>     Serial.println(String("Start: ") +
>                    t.getStartHour() + ":" +
>                    t.getStartMinute() + ":" +
>                    t.getStartSecond());
> BLYNK_WRITE(V3)
> {   
>   redValue1 = param[0].asInt();
>   greenValue1 = param[1].asInt();
>   blueValue1 = param[2].asInt();
> 
>   analogWrite(RED_PIN, redValue);
>   analogWrite(GREEN_PIN, greenValue);
>   analogWrite(BLUE_PIN, blueValue);
> 
> }
>               
>    }
>    
>    if ((t.hour ==  t.getStopHour() && t.min == t.getStopMinute())
>   {
>     Serial.println(String("Stop: ") +
>                    t.getStopHour() + ":" +
>                    t.getStopMinute() + ":" +
>                    t.getStopSecond());
> BLYNK_WRITE(V3)
> {   
>   redValue1 = param[0].asInt();
>   greenValue1 = param[1].asInt();
>   blueValue1 = param[2].asInt();
> 
>   analogWrite(RED_PIN, redValue*0);
>   analogWrite(GREEN_PIN, greenValue*0);
>   analogWrite(BLUE_PIN, blueValue*0);
> 
> }
>             
>   }
> 
>   //2. time input
>   
>   BLYNK_WRITE(V7) {  
>   TimeInputParam t(param);
> }
> 
>   if ((t.hour == t.getStartHour() && t.min == t.getStartMinute())
>   {
>     Serial.println(String("Start: ") +
>                    t.getStartHour() + ":" +
>                    t.getStartMinute() + ":" +
>                    t.getStartSecond());
> BLYNK_WRITE(V4)
> {   
>   redValue2 = param[0].asInt();
>   greenValue2 = param[1].asInt();
>   blueValue2 = param[2].asInt();
> 
>   analogWrite(RED_PIN, redValue);
>   analogWrite(GREEN_PIN, greenValue);
>   analogWrite(BLUE_PIN, blueValue);
> 
> }
> 
>    }
>    
>    if ((t.hour == t.getStopHour() && t.min == t.getStopMinute())
>   {
>     Serial.println(String("Stop: ") +
>                    t.getStopHour() + ":" +
>                    t.getStopMinute() + ":" +
>                    t.getStopSecond());
> BLYNK_WRITE(V4)
> {   
>   redValue2 = param[0].asInt();
>   greenValue2 = param[1].asInt();
>   blueValue2 = param[2].asInt();
> 
>   analogWrite(RED_PIN, redValue*0);
>   analogWrite(GREEN_PIN, greenValue*0);
>   analogWrite(BLUE_PIN, blueValue*0);
> 
> }
>                
>   }
> 
>   //3. time input
>   
> }/////bitiş
> 
> 
> void loop()
> {
>   
>   Blynk.run();
> }
> 
> 

I am 15 years old and my english is not good. I’m sorry if I made a mistake. Thank you.

@baltazar please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

I did what he said. So can you help with the code please

It would help enormously if you added some information about what type of widgets are connected to the virtual pins used in your code, and explained the operational function of these widgets.

You should also read this, and implement its suggestions:

Pete.

I edit. Thank you for your help in advance

But you haven’t changed your void loop, and haven’t removed the delay.
You don’t need to read the time from the RTC module each time the void loop executes. The ESP’s internal clock is very accurate, it just needs to be told the current time when the ESP boots and re-synchronised maybe once per day if you want high accuracy.

Checking for an exact time match isn’t the way to do this type of thing, as it relies on everything synchronising at exactly the same moment.
Also, is there any reason why you are using a physical RTC module rather than the Blynk RTC widget?

Are you using a single RGB LED, or RGB strips? If it’s the latter then how are you driving these strips?

Pete.

I drive a single rgb led with pwm pins on the Arduino mega. The reason I don’t use DS1302 is because it is mandatory. I used the ds1302 module before. When I compile the code, I do not get an error, but the system does not work. I think the system got confused because it uses multiple time inputs and zergba.