so i have wired up an RGB strip correctly and it all works, i just need some help with the code.
bellow is the code, and in the //'s is the time i would like the fade/the over all time for that cycle to last. at the moment I'm getting a strobe effect. i did pinch the sketch from a tutorial online and tried to modify it. also, how do i get by the 50 day millis reset, or should the sketch be ok to carry on running after the 50 days?
thanks for any help!
int brightness = 0;
int fadeAmount = 5;
int rPin=9;
int gPin=10;
int bPin=11;
unsigned long currentTime;
unsigned long loopTime;
void setup() {
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11,OUTPUT);
currentTime = millis();
loopTime = currentTime;
}
//DAWNORANGE fade for 30 minues
void loop() {
currentTime = millis();
if(currentTime >= (loopTime + 20)){
analogWrite(9, 161);
analogWrite(10,158);
analogWrite(11,156);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
//DAWNYELLOW fade for 30minutes
{
currentTime = millis();
if(currentTime >= (loopTime + 20)){
// set the brightness of pin 9:
analogWrite(9, 163);
analogWrite(10,159);
analogWrite(11,150);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
{ //CARBONARC fade for 30 minutes
currentTime = millis();
if(currentTime >= (loopTime + 20)){
analogWrite(9, 255);
analogWrite(10,250);
analogWrite(11,244);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
{ //FULLSUN fade for 3.5 hours
currentTime = millis();
if(currentTime >= (loopTime + 20)){
// set the brightness of pin 9:
analogWrite(9, 250);
analogWrite(10,250);
analogWrite(11,250);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
{ //HIGHNOON fade for 1 hour
currentTime = millis();
if(currentTime >= (loopTime + 20)){
analogWrite(9, 255);
analogWrite(10,255);
analogWrite(11,251);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
{ //FULLSUN stay for 7 hours
currentTime = millis();
if(currentTime >= (loopTime + 20)){
analogWrite(9, 255);
analogWrite(10,255);
analogWrite(11,255);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
{ //DUSKORANGE fade for 30minutes
currentTime = millis();
if(currentTime >= (loopTime + 20)){
analogWrite(9, 250);
analogWrite(10,214);
analogWrite(11,165);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
//DUSK BLUE fade for 30 minutes
{
currentTime = millis();
if(currentTime >= (loopTime + 20)){
// set the brightness of pin 9:
analogWrite(9, 38);
analogWrite(10,83);
analogWrite(11,141);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
{ //moonlightblue for 1 hour
currentTime = millis();
if(currentTime >= (loopTime + 20)){
analogWrite(9, 0);
analogWrite(10,85);
analogWrite(11,165);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
//MIDNIGHTBLUE 1hour
{currentTime = millis();
if(currentTime >= (loopTime + 20)){
analogWrite(9, 161);
analogWrite(10,158);
analogWrite(11,156);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
//night 8hours
{currentTime = millis();
if(currentTime >= (loopTime + 20)){
analogWrite(9, 0);
analogWrite(10,0);
analogWrite(11,0);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
loopTime = currentTime;
}
}
}
}
}
}
}
}
}
}
}
}