X-Git-Url: http://git.piffa.net/web?a=blobdiff_plain;f=basic%2Fpwm%2Fpwm_1_while_byte%2Fpwm_1_while_byte.ino;h=fed4e7f0e70c8c96bf4583e680aa5c53966cfcbc;hb=3b78d813afb2e27ed29faa261570d2eeb8d5068d;hp=cf5451afd453f2657a708115b9463ebc024e4226;hpb=8bbff1c558947ca1ff1733240827c87494ff4fd5;p=sketchbook_andrea diff --git a/basic/pwm/pwm_1_while_byte/pwm_1_while_byte.ino b/basic/pwm/pwm_1_while_byte/pwm_1_while_byte.ino index cf5451a..fed4e7f 100644 --- a/basic/pwm/pwm_1_while_byte/pwm_1_while_byte.ino +++ b/basic/pwm/pwm_1_while_byte/pwm_1_while_byte.ino @@ -4,8 +4,9 @@ PWM per un LED: aumentare progressivamente la luminosita'. */ -byte led = 9 ; // Il pin ~9 e' abilitato al PWM -byte brightness = 0; // Valore iniziale per il PWM del LED +const byte led = 9 ; // Il pin ~9 e' abilitato al PWM +byte brightness = 0; // Valore iniziale per il PWM del LED + // Perche' brightness non e' una costante? // the setup routine runs once when you press reset: void setup() { @@ -13,10 +14,11 @@ void setup() { } void loop() { - analogWrite(led, brightness++); // La funziona analogWrite utilizza il PWM + analogWrite(led, brightness); // La funziona analogWrite utilizza il PWM // a 8 bit integrato nel MCU: simula un serie di valori intermedi // nell'intervallo discreto con minimo 0 (spento) e massimo 255 (acceso). delay(10); + brightness = brightness + 1; // Incrementiamo la luminosita' } /* Domande: