mashm:
sorry for my bad english...i will try again to explain my idea:
the lamp starts with both leds of (Initial state). now i press the button and the Output of the White should be 1/4 pwm:
So, maybe you need two variables, to record the current state of each of the LEDs.
ledBlueState = 0;
ledWhiteState = 0;
if (switchWasPressed) {
if((ledBlueState == 100) && (ledWhiteState == 100)) {
ledBlueState = 0;
ledWhiteState = 0;
}
else if((ledBlueState == 0) && (ledWhiteState == 100)) {
ledBlueState = 100;
}
else {
ledWhiteState += 25;
}
}
i am not a programmer
I am a diver, mainly in the English Channel where a good torch is essential. Sorry to go off topic but I am going to ask you to think carefully about your design decision. Underwater torches which go from 100% to off, when what you want to do is turn the brightness down, are extremely annoying.
On the surface, a bright torch allows you to see further but underwater, the distance is limited by the particles in the water, reducing your depth of field, which a torch does not alter. You don't need a lot of light when it is dark underwater, because your iris opens up and after a few minutes you have very good night vision. When there is not much ambient light, turning your torch up causes more light to be reflected back from the particles in the water (backscatter) and reduces your night vision - much quicker than the time it takes to recover. It sounds counter intuitive but underwater, a bright light is most useful when there is lots of ambient light around and your night vision is already limited.
A torch which goes from very bright to off, when there is little ambient light around, will leave you just about blind. I think it would be better, safer even, for your torch to go 0->25->50->100->50->25->0. To be honest, I would much prefer a separate on/off switch, well away from the power adjustment. Similarly with the low battery. Don't flash the torch as that can ruin night vision and leave you blind. Dim the torch, relative to the power it is set at.