I'd GOSUB for a complex CASE with IF statements.

You can also merge the last 2 IFs:
Code:
    B_PWM=4095 
    Blue_Day_Cycle = DAY
Robert