diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-12-15 01:50:56 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-12-15 16:16:31 -0500 |
commit | 7f31099eead99718d279d9a4bb543131329891ce (patch) | |
tree | d1bca663d7a8e3541085951664ecf26bea31c006 /source/lang/api/pwmwrite.rst | |
parent | 210f3d2b1555bae87c9de27ea145e16d3bddb0f8 (diff) | |
download | librambutan-7f31099eead99718d279d9a4bb543131329891ce.tar.gz librambutan-7f31099eead99718d279d9a4bb543131329891ce.zip |
Finalized 0.0.9 documentation.
Diffstat (limited to 'source/lang/api/pwmwrite.rst')
-rw-r--r-- | source/lang/api/pwmwrite.rst | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source/lang/api/pwmwrite.rst b/source/lang/api/pwmwrite.rst index 7a1d51f..2c858ab 100644 --- a/source/lang/api/pwmwrite.rst +++ b/source/lang/api/pwmwrite.rst @@ -11,6 +11,13 @@ pwmWrite(), the pin will output a steady square wave with the given duty cycle. You can change the duty cycle later by calling pwmWrite() again with the same pin and a different duty. +On the Maple, the pins which support PWM are: 0, 1, 2, 3, 5, 6, 7, 8, +9, 11, 12, 14, 24, 27, and 28. + +The Arduino function :ref:`analogWrite() <lang-analogwrite>` is an +alias for ``pwmWrite()``, but it is badly named, and its use is +discouraged. + .. contents:: Contents :local: @@ -25,12 +32,11 @@ Example Sets the output to the LED proportional to the value read from the potentiometer:: - int ledPin = 13; // LED connected to pin 13 (Maple) int analogPin = 3; // potentiometer connected to analog pin 3 int val = 0; // variable to store the read value void setup() { - pinMode(ledPin, OUTPUT); // sets the LED pin as output + pinMode(BOARD_LED_PIN, OUTPUT); // sets the LED pin as output pinMode(analogPin, PWM); // sets the potentiometer pin as PWM // output @@ -39,8 +45,9 @@ potentiometer:: void loop() { val = analogRead(analogPin); // read the input pin - analogWrite(ledPin, val / 16); // analogRead values go from 0 to 4095, - // analogWrite values from 0 to 65535 + analogWrite(BOARD_LED_PIN, val / 16); // analogRead values go from 0 + // to 4095, analogWrite values + // from 0 to 65535 } See Also |