Reference for Wiring version 0027+. 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 = 37;
int val = 0;
void setup() {
pinMode(outpin, OUTPUT); // set the PWM pin as OUTPUT
}
void loop() {
analogWrite(outpin, val); // sets the value of PWM pin 29
val = (val + 10) % 1023; // increment value and keep it in
// the 0-1023 range.
} |
Description |
The analogWrite() method sets the value of a PWM output pin. Possible values range from 0 to 1023. The analogWrite() command works on PWM output pins 29, 30, 31, 35, 36 and 37 only. |
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 September 17, 2010 12:09:44pm PDT