how is it possible when the first int reaches 5 to start the next session
as i figure first calculates the first and when finish goes to the next session
if (daybyminute >= (ontime*60))
{
if (daybyminute <= ((ontime*60) + blueramptime + (whiteramptime/10*9))) //if time is in range of fade in, start fading in + (whiteramptime/10*9)
{
// fade blue LEDs in from min to max.
for (int i = 1; i <= 10; i++) // setting ib value for 10% increment. Start with 0%
{
analogWrite(blue, bluepercent[i]);
lcd.setCursor(2, 1);
lcd.print(i);
lcd.print(" ");
int countdown = ((bluerampup*60)/10); // calculates seconds to next step
while (countdown>0)
{
onesecond(); // updates clock once per second
countdown--;
}
}
// fade white LEDs in from min to max.
for (int i = 1; i <= 10; i++) // setting i value for 10% increment. Start with 0%
{
analogWrite(white, whitepercent[i]);
lcd.setCursor(7, 1);
lcd.print(i);
lcd.print(" ");
int countdown = ((whiterampup*60)/10); // calculates seconds to next step
while (countdown>0)
{
onesecond(); // updates clock once per second
countdown--;
}
}
}
}
whatever i try its a failure
if you can just explain me what i have to do
thanks in advance
Depending on what you are after and if I understand you right.
You can either alter line 6 and change the condition to break on 5 rather than 10. Or you can place an if statement somewhere within the for loop to break when i equals 5.
Let's say, that you want to create the loop that outputs numbers from 1 to 10, but when it reaches 5 the next loop starts that, let's say, outputs numbers from 5 to 1. Then previous loop continues.
This code is simple enough for you to understand. I think you might want something like that.
If you don't know how to create if statements, check this site:
if (daybyminute >= (ontime*60))
{
if (daybyminute <= ((ontime*60) + blueramptime + (whiteramptime/10*9))) //if time is in range of fade in, start fading in + (whiteramptime/10*9)
{
int main(){
for (int i = 1; i <= 10; i++) // setting ib value for 10% increment. Start with 0%
{
{
analogWrite(white, whitepercent[i]);
lcd.setCursor(7, 1);
lcd.print(i);
lcd.print(" ");
)
if(i == 5){
for(int j = 5; j > 0; j--){
int countdown = ((whiterampup*60)/10); // calculates seconds to next step
while (countdown>0)
{
onesecond(); // updates clock once per second
countdown--;
}
}
}
{
analogWrite(blue, bluepercent[i]);
lcd.setCursor(2, 1);
lcd.print(j);
lcd.print(" ");
int countdown = ((bluerampup*60)/10); // calculates seconds to next step
while (countdown>0)
{
onesecond(); // updates clock once per second
countdown--;
}
}
}
}
}
}