Coding the Dimming Expansion

Do you have a question on how to do something.
Ask in here.
Post Reply
pisanoal1
Posts: 16
Joined: Sun Nov 30, 2014 3:17 pm

Coding the Dimming Expansion

Post by pisanoal1 »

Hello,

I am trying to code 3 DC pumps to work in gyre flow (not gyre mode) that will reverse every few hours. I have the pumps set up on opposite sides of the tank, 2 on one, one on the other (along with the return that is not included in coding) I tried to manually do if statements for several periods of the day where the stand alone pump comes on at 100% while the other 2 are off. Then after a couple hours, it shuts off, and the other two on the opposite side come on. I also have a few turbulent flow times coded in where all pumps are running. The issue i am having is that when i upload the below code, the if statements do not work, and only the last condition is used.
    ////// Place your custom code below here
    
    if (hour()>=7 || hour()<9) {
        ReefAngel.PWM.SetChannel( 1, 100);
        ReefAngel.PWM.SetChannel( 2, 0);
        ReefAngel.PWM.SetChannel( 0, 0);
     }
    if (hour()>=9 || hour()<11) {
        ReefAngel.PWM.SetChannel( 2, 100);
        ReefAngel.PWM.SetChannel( 0, 100);
        ReefAngel.PWM.SetChannel( 1, 0);
     }
     if (hour()>=11 || hour()<12) {
        ReefAngel.PWM.SetChannel( 1, 50);
        ReefAngel.PWM.SetChannel( 2, 100);
        ReefAngel.PWM.SetChannel( 0, 100);
     }
     if (hour()>=12 || hour()<15) {
        ReefAngel.PWM.SetChannel( 1, 100);
        ReefAngel.PWM.SetChannel( 2, 0);
        ReefAngel.PWM.SetChannel( 0, 0);
     }
     if (hour()>=15 || hour()<19) {
        ReefAngel.PWM.SetChannel( 1, 100);
        ReefAngel.PWM.SetChannel( 2, 100);
        ReefAngel.PWM.SetChannel( 0, 100);
     }
     if (hour()>=19 || hour()<22) {
        ReefAngel.PWM.SetChannel( 1, 0);
        ReefAngel.PWM.SetChannel( 2, 100);
        ReefAngel.PWM.SetChannel( 0, 100);
     }
     if (hour()>=22 || hour()<2) {
        ReefAngel.PWM.SetChannel( 1, 100);
        ReefAngel.PWM.SetChannel( 2, 0);
        ReefAngel.PWM.SetChannel( 0, 0);
     }
     if (hour()>=2 || hour()<7) {
        ReefAngel.PWM.SetChannel( 1, 0);
        ReefAngel.PWM.SetChannel ( 2, 80);
        ReefAngel.PWM.SetChannel ( 0, 80);
     }
        // This should always be the last line
channel 0 and 2 are on one side while channel 1 is on the other


I thought about maybe doing it differently and defining conditions and then doing some like
if (hour>=7 && hour<10) Preset Condition
where the preset condition would be one of 3 or 4 that i defined as a combination of pumps on and off and speeds.

I havent messed around a whole lot with programming stuff on my own. I usually just try to take something else that someone has posted thats close and figure out how to make it work for mine, but im having a hard time with this one.


Thanks for the help.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Coding the Dimming Expansion

Post by cosmith71 »

Should be like this:

Code: Select all

 if (hour()>=7 && hour()<9) {
        ReefAngel.PWM.SetChannel( 1, 100);
        ReefAngel.PWM.SetChannel( 2, 0);
        ReefAngel.PWM.SetChannel( 0, 0);
     }
    if (hour()>=9 && hour()<11) {
        ReefAngel.PWM.SetChannel( 2, 100);
        ReefAngel.PWM.SetChannel( 0, 100);
        ReefAngel.PWM.SetChannel( 1, 0);
     }
     if (hour()>=11 && hour()<12) {
        ReefAngel.PWM.SetChannel( 1, 50);
        ReefAngel.PWM.SetChannel( 2, 100);
        ReefAngel.PWM.SetChannel( 0, 100);
     }
     if (hour()>=12 && hour()<15) {
        ReefAngel.PWM.SetChannel( 1, 100);
        ReefAngel.PWM.SetChannel( 2, 0);
        ReefAngel.PWM.SetChannel( 0, 0);
     }
     if (hour()>=15 && hour()<19) {
        ReefAngel.PWM.SetChannel( 1, 100);
        ReefAngel.PWM.SetChannel( 2, 100);
        ReefAngel.PWM.SetChannel( 0, 100);
     }
     if (hour()>=19 && hour()<22) {
        ReefAngel.PWM.SetChannel( 1, 0);
        ReefAngel.PWM.SetChannel( 2, 100);
        ReefAngel.PWM.SetChannel( 0, 100);
     }
     if (hour()>=22 || hour()<2) {
        ReefAngel.PWM.SetChannel( 1, 100);
        ReefAngel.PWM.SetChannel( 2, 0);
        ReefAngel.PWM.SetChannel( 0, 0);
     }
     if (hour()>=2 && hour()<7) {
        ReefAngel.PWM.SetChannel( 1, 0);
        ReefAngel.PWM.SetChannel ( 2, 80);
        ReefAngel.PWM.SetChannel ( 0, 80);
     }
        // This should always be the last line

Post Reply