4 Impostare la frequenza del PWM tramite un input analogico.
8 int inputPin = A0; // set input pin for the potentiometer
9 int inputValue = 0; // potentiometer input variable
10 int ledPin = 3; // output pin, deve avere il PWM
13 // declare the ledPin as an OUTPUT:
14 pinMode(ledPin, OUTPUT);
18 // read the value from the potentiometer:
19 inputValue = analogRead(inputPin);
21 // send the square wave signal to the LED:
22 analogWrite(ledPin, inputValue/4);
23 // la lettura analogica e' a 10 bit (0-1024)
24 // Il PWM invece e' a 8 bit (0-255)
25 // Circa 1024 / 4 ~= 255
27 // Domanda: dovrebbe esserci un delay()?