I have an RGB LED strip connected to D5,D3 & D6 as RED GREEN BLUE
I controlling this with IRLZ44N Mosfet , Arduino UNO and hc-06.
I am trying to allow the user to either manually choose a colour using a ZERGBA set to the RGB pins in split mode and the user can push a button on the app set to V1 to fade mode the RGB LED.
I have copied the fading code but need help implementing the button to switch the “mode”
I also want to add a slider to V2 to change the speed of the fade
NOTE: I already controlling led with ZeRGBa
My Fade code is;
analogWrite(5, 255);
analogWrite(3, 255);
analogWrite(6, 255);
for (i = 90; i <= 270; i++)
rad = DEG_TO_RAD * i;
sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
analogWrite(3, sinOut);
delay(15);
}
for (i = 90; i <= 270; i++)
rad = DEG_TO_RAD * i;
sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
analogWrite(6, sinOut);
delay(15);
}
for (i = 270; i >= 90; i--)
rad = DEG_TO_RAD * i;
sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
analogWrite(3, sinOut);
delay(15);
}
for (i = 90; i <= 270; i++)
rad = DEG_TO_RAD * i;
sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
analogWrite(5, sinOut);
delay(15);
}
for (i = 270; i >= 90; i--)
rad = DEG_TO_RAD * i;
sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
analogWrite(6, sinOut);
delay(15);
}
for (i = 90; i <= 270; i++)
rad = DEG_TO_RAD * i;
sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
analogWrite(3, sinOut);
delay(15);
}
for (i = 270; i >= 90; i--)
rad = DEG_TO_RAD * i;
sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
analogWrite(3, sinOut);
analogWrite(5, sinOut);
delay(15);
}
First of all, the title of your topic talks about an Arduino Uno and an LED strip, but the body of the text talks about a particle photon and a single RGB LED.
You can’t simply replace a single LED with a strip, otherwise you’ll burn-out whichever MCU it is that you are using. You probably need to use suitable MOSFETs to drive the LED strip.
Forum members aren’t likely to write your code for you, but if you give it your best go at combining the two pieces of code and share what you’ve done and the issues you’re experiencing (along with accurate information about your hardware) then you may get some assistance from forum members.
The problem with doing fade routines like the one you’ve posted above is that the code takes a while to execute (that’s the whole idea, otherwise it wouldn’t be a fade).
While it’s executing, nothing else is getting any processor time, because you’re running the code on a single threaded machine. The Blynk library needs frequent processor time to prevent the connection to the server being dropped, and for Blynk commands from the app via the server to be recognised.
The simple solution is to add Blynk.run(); commands into your fade routine at key points so that they get called while the fade is happening.
The thing you’re doing in the void loop with the switch/case command isn’t very Blynk friendly either, as it has to be evaluated during every single cycle of the void loop, which should be happening hundreds if not thousands of times per second.
I’m not really clear why you aren’t calling the fade routine directly from your BLYNK_WRITE(V1) function.