You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to `analogWrite()`, the pin will generate a steady square wave of the specified duty cycle until the next call to `analogWrite()` (or a call to `digitalRead()` or `digitalWrite()`) on the same pin. The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno and similar boards, pins 5 and 6 have a frequency of approximately 980 Hz.
19
+
=== Descrizione
20
+
Scrive un valore analogico (http://arduino.cc/en/Tutorial/PWM[onda PWM]) ad un pin.
21
+
Può essere usato per illuminare un LED a luminosità variabile o pilotare un motore a diverse velocità.
22
+
Dopo una chiamata a `analogWrite()`, il pin genererà un'onda quadra costante con il duty cycle specificato fino alla prossima chiamata a `analogWrite()` ( oppure `digitalRead()` o `digitalWrite()` ) sullo stesso pin.
23
+
La frequenza del segnale PWM su molti pin è approssimativamente 490 Hz.
24
+
Sulla Uno e schede simili, i pin 5 e 6 hanno una frequenza di circa 980 Hz.
21
25
[%hardbreaks]
22
-
On most Arduino boards (those with the ATmega168 or ATmega328P), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 - 13 and 44 - 46. Older Arduino boards with an ATmega8 only support `analogWrite()` on pins 9, 10, and 11.
23
-
The Arduino DUE supports `analogWrite()` on pins 2 through 13, plus pins DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs.
24
-
You do not need to call `pinMode()` to set the pin as an output before calling `analogWrite()`.
25
-
The `analogWrite` function has nothing to do with the analog pins or the `analogRead` function.
26
+
Sulla maggior parte delle schede Arduino ( quelle con ATmega168 o ATmega328P ), questa funzione lavora sui pin 3, 5, 6, 9, 10, e 11.
27
+
Sull'Arduino Mega, lavora sui pin dal 2 al 13 e dal 44 al 46.
28
+
Le schede Arduino più vecchie con un ATmega8 supportano `analogWrite()` solo sui pin 9, 10, e 11.
29
+
Arduino DUE supporta `analogWrite()` sui pin da 2 a 13, oltre che sui pin DAC0 e DAC1.
30
+
Diversamente dai pin PWM, DAC0 e DAC1 sono convertitori digitale-analogico, e si comportano come veri output analogici.
31
+
Non hai bisogno di chiamare `pinMode()` per impostare il pin come output prima di chiamare `analogWrite()`.
32
+
La funzione `analogWrite` non ha nulla a che vedere con i pin analogici o la funzione `analogRead`.
26
33
[%hardbreaks]
27
34
28
35
29
36
[float]
30
-
=== Syntax
31
-
`analogWrite(pin, value)`
37
+
=== Sintassi
38
+
`analogWrite(pin, valore)`
32
39
33
40
34
41
[float]
35
42
=== Parameters
36
-
`pin`: the pin to write to. Allowed data types: int. +
37
-
`value`: the duty cycle: between 0 (always off) and 255 (always on). Allowed data types: int
43
+
`pin`: Il pin sul quale scrivere. Tipi di dato permessi: int. +
44
+
`valore`: il duty cycle: tra 0 ( sempre spento ) e 255 ( sempre acceso ). Tipi di dato permessi: int
38
45
39
46
40
47
[float]
@@ -52,33 +59,33 @@ Nothing
52
59
--
53
60
54
61
[float]
55
-
=== Example Code
56
-
Sets the output to the LED proportional to the value read from the potentiometer.
62
+
=== Codice di Esempio
63
+
Imposta l'output del LED in modo proporzionale al valore letto dal potenziometro.
57
64
58
65
59
66
[source,arduino]
60
67
----
61
-
int ledPin = 9; // LED connected to digital pin 9
62
-
int analogPin = 3; // potentiometer connected to analog pin 3
63
-
int val = 0; // variable to store the read value
68
+
int ledPin = 9; // il LED connesso al pin 9
69
+
int analogPin = 3; // potenziometro connesso al pin A3
70
+
int val = 0; // variabile per conservare il valore letto
64
71
65
72
void setup()
66
73
{
67
-
pinMode(ledPin, OUTPUT); // sets the pin as output
74
+
pinMode(ledPin, OUTPUT); // imposta il pin come output
68
75
}
69
76
70
77
void loop()
71
78
{
72
-
val = analogRead(analogPin); // read the input pin
73
-
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
79
+
val = analogRead(analogPin); // leggi il pin di input
80
+
analogWrite(ledPin, val / 4); // i valori di analogRead vanno da 0 a 1023, i valori di analogWrite da 0 a 255
74
81
}
75
82
----
76
83
[%hardbreaks]
77
84
78
85
79
86
[float]
80
-
=== Notes and Warnings
81
-
The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the `millis()` and `delay()` functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g. 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6.
87
+
=== Note e Avvertimenti
88
+
Gli output PWM generati sui pin 5 e 6 avranno un duty cyle più alto di quello atteso. Questo a causa dell'interazione con le funzioni `millis()` e `delay()`, che condividono lo stesso timer interno usato per generare questi output PWM. Questo si noterà in particolare con impostazioni basse del duty-cycle (es. 0 - 10) e potrebbe risultare in un valore di 0 che non spegne completamente l'output sui pin 5 e 6.
82
89
83
90
--
84
91
// HOW TO USE SECTION ENDS
@@ -89,16 +96,16 @@ The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cy
0 commit comments