diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-02-08 22:19:40 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-02-08 22:19:40 -0500 |
commit | 9ea60c7e7dffd06791ec2dc62ffab3f2bf802f08 (patch) | |
tree | a27793c8b0ce41e302da00979542b61f7030b679 /source/lang/api/pwmwrite.rst | |
parent | 63c03fe6d1aeada3d6c581bacd6c1229b00374b4 (diff) | |
download | librambutan-9ea60c7e7dffd06791ec2dc62ffab3f2bf802f08.tar.gz librambutan-9ea60c7e7dffd06791ec2dc62ffab3f2bf802f08.zip |
Documentation bugfixes
Diffstat (limited to 'source/lang/api/pwmwrite.rst')
-rw-r--r-- | source/lang/api/pwmwrite.rst | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/lang/api/pwmwrite.rst b/source/lang/api/pwmwrite.rst index 2c858ab..9d50077 100644 --- a/source/lang/api/pwmwrite.rst +++ b/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 |