I see, i see. I thought that when we use an "if", it returns to the "if" always until it has completed done the condition.
Now i know that i must use and extra condition to keep it inside the loop.
I'll try to use the serial port as you say Cybernetician.
Only one question please:
- Is possible use pwm in 6 outputs at the same time ?.
I have thought that correct way would be going pin by pin increasing step by step util it goes to the maximum(255) and the same for decreasing until zero. But i can't use pw1 at pin 3 and pwm2 at pin5, and pwm3 at pin, ..... because the code is read up to down and if it is inside a loop never will go to the next, isn't it?
Thanks again for all your help, i's been very very good.
Finally it is this way and it works just i want:
int led = 11; // the pin that the LED is attached to
int brightness = 1; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led,LOW);
delay(1000);
//statement you need do and wihle
do{
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 1 || brightness == 200) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(10);
}while(0 !=brightness);//statement you need
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.