diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-11-21 01:40:37 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-11-21 01:40:37 -0500 |
commit | c770a7f14404822c1164a2399079411a37808cfd (patch) | |
tree | 599188be6e3a5d105f9b8c4baba19d280b3d1058 /source/wirish/pwmwrite.rst | |
parent | 4b60b1cad5fe16895179d0bd8a5dc1e6e4c7564c (diff) | |
download | librambutan-c770a7f14404822c1164a2399079411a37808cfd.tar.gz librambutan-c770a7f14404822c1164a2399079411a37808cfd.zip |
updated serial bootloader spec; other improvements
Diffstat (limited to 'source/wirish/pwmwrite.rst')
-rw-r--r-- | source/wirish/pwmwrite.rst | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/wirish/pwmwrite.rst b/source/wirish/pwmwrite.rst index b1f0515..7667a72 100644 --- a/source/wirish/pwmwrite.rst +++ b/source/wirish/pwmwrite.rst @@ -24,26 +24,25 @@ Example Sets the output to the LED proportional to the value read from the potentiometer (adapted for Maple from the Arduino `analogWrite() -reference <http://www.arduino.cc/en/Reference/AnalogWrite>`_\ ):: +reference <http://www.arduino.cc/en/Reference/AnalogWrite>`_):: - - int ledPin = 13; // LED connected to pin 13 (Maple-specific) + + 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(analogPin, PWM); // sets the potentiometer pin as PWM - // output (Maple-specific) + // output } - + 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 - // (Maple-specific) } See Also |