aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/lang/api/pwmwrite.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-02-08 22:19:40 -0500
committerMarti Bolivar <mbolivar@leaflabs.com>2011-02-08 22:19:40 -0500
commit90adb6bff63e3ecad81d300651a40d8835efc608 (patch)
tree17a4641d6da3face5cb31e4027f51ca00e646ddb /docs/source/lang/api/pwmwrite.rst
parent8ffa051f2df2b380930ca10ce030134b57b976d3 (diff)
downloadlibrambutan-90adb6bff63e3ecad81d300651a40d8835efc608.tar.gz
librambutan-90adb6bff63e3ecad81d300651a40d8835efc608.zip
Documentation bugfixes
Diffstat (limited to 'docs/source/lang/api/pwmwrite.rst')
-rw-r--r--docs/source/lang/api/pwmwrite.rst13
1 files changed, 6 insertions, 7 deletions
diff --git a/docs/source/lang/api/pwmwrite.rst b/docs/source/lang/api/pwmwrite.rst
index 2c858ab..9d50077 100644
--- a/docs/source/lang/api/pwmwrite.rst
+++ b/docs/source/lang/api/pwmwrite.rst
@@ -33,21 +33,20 @@ Sets the output to the LED proportional to the value read from the
potentiometer::
int analogPin = 3; // potentiometer connected to analog pin 3
- int val = 0; // variable to store the read value
void setup() {
pinMode(BOARD_LED_PIN, OUTPUT); // sets the LED pin as output
- pinMode(analogPin, PWM); // sets the potentiometer pin as PWM
- // output
+ pinMode(analogPin, INPUT_ANALOG); // sets the potentiometer pin as
+ // analog input
}
void loop() {
- val = analogRead(analogPin); // read the input pin
+ int val = analogRead(analogPin); // read the input pin
- analogWrite(BOARD_LED_PIN, val / 16); // analogRead values go from 0
- // to 4095, analogWrite values
- // from 0 to 65535
+ pwmWrite(BOARD_LED_PIN, val * 16); // analogRead values go from 0
+ // to 4095, pwmWrite values
+ // from 0 to 65535, so scale roughly
}
See Also