Do you have a question on how to do something.
Ask in here.
Smotz
Posts: 401 Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
Post
by Smotz » Wed May 29, 2013 6:09 am
Hi -
I want my code to say:
If in feeding mode, my wave should be set to 35%
else, set normally, unless between hours x and y then set slightly lower. The coding doesn't seem to like the nested 'Else' statements..
Code: Select all
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(35);
ReefAngel.PWM.SetActinic(35);
}
else {
if ( (hour() >= 5) && (hour() < 23) ) // from 5a - 11p
ReefAngel.PWM.SetDaylight( SineMode(35,45,60,false) );
}
else {
////ReefAngel.PWM.SetDaylight(50);
ReefAngel.PWM.SetDaylight( SineMode(35,65,45,false) );
ReefAngel.PWM.SetActinic( ReefCrestMode(50,25,false) ); // ReefCrest at 50% +/- 25% on anti-sync mode
}
Smotz
Posts: 401 Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
Post
by Smotz » Wed May 29, 2013 6:12 am
I think I got it - too many '{}' 's
hopefully this will work - thoughts?
Code: Select all
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(35);
ReefAngel.PWM.SetActinic(35);
}
else {
if ( (hour() >= 5) && (hour() < 23) ) // from 5a - 11p
ReefAngel.PWM.SetDaylight( SineMode(35,45,60,false) );
else
////ReefAngel.PWM.SetDaylight(50);
ReefAngel.PWM.SetDaylight( SineMode(35,65,45,false) );
ReefAngel.PWM.SetActinic( ReefCrestMode(50,25,false) ); // ReefCrest at 50% +/- 25% on anti-sync mode
}
lnevo
Posts: 5422 Joined: Fri Jul 20, 2012 9:42 am
Post
by lnevo » Wed May 29, 2013 6:19 am
You actually have not enough...
Try this
Code: Select all
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(35);
ReefAngel.PWM.SetActinic(35);
}
else {
if ( (hour() >= 5) && (hour() < 23) ) // from 5a - 11p
ReefAngel.PWM.SetDaylight( SineMode(35,45,60,false) );
else {
////ReefAngel.PWM.SetDaylight(50);
ReefAngel.PWM.SetDaylight( SineMode(35,65,45,false) );
ReefAngel.PWM.SetActinic( ReefCrestMode(50,25,false) ); // ReefCrest at 50% +/- 25% on anti-sync mode
}
}[/quote]
Smotz
Posts: 401 Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
Post
by Smotz » Wed May 29, 2013 6:32 am
lnevo wrote: You actually have not enough...
Try this
Code: Select all
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(35);
ReefAngel.PWM.SetActinic(35);
}
else {
if ( (hour() >= 5) && (hour() < 23) ) // from 5a - 11p
ReefAngel.PWM.SetDaylight( SineMode(35,45,60,false) );
else {
////ReefAngel.PWM.SetDaylight(50);
ReefAngel.PWM.SetDaylight( SineMode(35,65,45,false) );
ReefAngel.PWM.SetActinic( ReefCrestMode(50,25,false) ); // ReefCrest at 50% +/- 25% on anti-sync mode
}
}[/quote]
thx man - you're the best - couldn't figure out why it wasn't working
Smotz
Posts: 401 Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
Post
by Smotz » Wed May 29, 2013 6:37 am
Actually - still not working.
Can you confirm my time schedule? It's 9:36 am and my wave is running on the night schedule..?
it is backwards..fixing..
lnevo
Posts: 5422 Joined: Fri Jul 20, 2012 9:42 am
Post
by lnevo » Wed May 29, 2013 7:06 am
Yeah, looking at your logic... if the hour is greater than 5 and less then 23 go at SineMode 35%.-45%, else 35-65 and Reefcrest at 50...
You can just switch the actions or, you can make the conditional
if ( (hour() < 5) || (hour() >=23) )
Smotz
Posts: 401 Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
Post
by Smotz » Wed May 29, 2013 7:26 am
Sorry for the basic stuff but can you explain the conditions?
Sent from my SCH-I605 using Tapatalk 4 Beta
binder
Posts: 2865 Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:
Post
by binder » Wed May 29, 2013 7:35 am
&& - means AND. both sides of the && must be TRUE in order for the whole expression to be true.
if ( (x > 1) && (x < 10) ) -- this means X must be between 1 AND 10 (or a value of 2 - 9) for it to be true.
|| - means OR. one of the sides must be TRUE in order for the whole expression to be true.
if ( (x < 10) || (x > 20) ) -- this means X must be less than 10 (0-9) OR greater than 20 (21 and higher) in order for the expression to be true.
lnevo
Posts: 5422 Joined: Fri Jul 20, 2012 9:42 am
Post
by lnevo » Wed May 29, 2013 7:38 am
Sorry my code wasn't correct so don't copy directly... I forgot the () for hour... (going to update it now...)
Anyway, you had said that IF the hour is greater then 5 AND the hour is less than 23 ... then be in Night mode which was the opposite of what you wanted... so your choice was to move the actions around... or change to this logic...
The code I posted says this... IF the hour is less than 5 OR the hour is greater than 23 then be in Night mode...
does that help?
Smotz
Posts: 401 Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
Post
by Smotz » Wed May 29, 2013 7:48 am
Gotcha. At work now but I definitely will have to review my code.
Sent from my SCH-I605 using Tapatalk 4 Beta