4 Impostare la frequenza del PWM tramite un input analogico.
6 - Schema: http://lab.piffa.net/schemi/arduino-pwm-diagram.png
10 const byte inputPin = A0;// set input pin for the potentiometer
11 int inputValue = 0; // potentiometer input variable
12 const byte ledPin = 3; // output pin, deve avere il PWM
15 // declare the ledPin as an OUTPUT:
16 pinMode(ledPin, OUTPUT);
20 // read the value from the potentiometer:
21 inputValue = analogRead(inputPin);
23 // send the square wave signal to the LED:
24 analogWrite(ledPin, inputValue/4);
25 // la lettura analogica e' a 10 bit (0-1024)
26 // Il PWM invece e' a 8 bit (0-255)
27 // Circa 1024 / 4 ~= 255
29 // Domanda: dovrebbe esserci un delay()?