From 90adb6bff63e3ecad81d300651a40d8835efc608 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 8 Feb 2011 22:19:40 -0500 Subject: Documentation bugfixes --- docs/source/lang/api/pwmwrite.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'docs/source/lang/api/pwmwrite.rst') 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 -- cgit v1.2.3