Reference for Wiring version 0024+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.
Name |
analogWrite() |
Examples |
int outpin = 0;
int val = 0;
void setup() {
}
void loop() {
analogWrite(outpin, val); // sets the value of analog pin 0
val = (val + 10) % 1023; // increment value and keep it in
// the 0-1023 range.
} |
Description |
The analogWrite() method sets the value of an analog output (PWM) pin. Possible values range from 0 to 1023, where 0 is 0 volts and 1023 is 5 volts. The analogWrite() command works on PWM (analog output) pins 0-5, note that these pins are the same 37, 36, 35, 31, 30 and 29 (in the Wiring I/O board they are in separate section for easiness). It is also possible to use the digital pin numbering 37, 36, 35, 31, 30 and 29 respectively. |
Syntax |
analogWrite(pin,value) |
Parameters |
pin |
int: The PWM output pin number |
value |
int: a value in the range 0-1023 |
|
Returns |
None |
Usage |
Application |
Related |
analogRead()
|
Updated on November 14, 2009 09:51:56pm PST