aboutsummaryrefslogtreecommitdiffstats
path: root/source/wirish
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-10-25 21:15:28 -0400
committerMarti Bolivar <mbolivar@mit.edu>2010-11-17 12:44:28 -0500
commit2d429e75ce69e77f8c95490ac03881ec9aa0354a (patch)
treea3b810a6c75625b07a4b976e5d1e319c60e19a6b /source/wirish
parent30ac55d80c18e93f9c39a6dd850c10f9e7fd92ac (diff)
downloadlibrambutan-2d429e75ce69e77f8c95490ac03881ec9aa0354a.tar.gz
librambutan-2d429e75ce69e77f8c95490ac03881ec9aa0354a.zip
arduino language reference nearing completion, properly CC-BY-SA 3.0 attributed
Diffstat (limited to 'source/wirish')
-rw-r--r--source/wirish/pwmwrite.rst52
-rw-r--r--source/wirish/types.rst6
2 files changed, 58 insertions, 0 deletions
diff --git a/source/wirish/pwmwrite.rst b/source/wirish/pwmwrite.rst
new file mode 100644
index 0000000..b1f0515
--- /dev/null
+++ b/source/wirish/pwmwrite.rst
@@ -0,0 +1,52 @@
+.. highlight:: cpp
+
+.. _wirish-pwmwrite:
+
+pwmWrite()
+==========
+
+Writes a :ref:`PWM wave <pwm>` to a pin. You can use this to make an
+LED get brighter or dimmer, control a servomotor, etc. After a call to
+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.
+
+.. contents:: Contents
+ :local:
+
+Library Documentation
+---------------------
+
+.. doxygenfunction:: pwmWrite
+
+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>`_\ )::
+
+
+ int ledPin = 13; // LED connected to pin 13 (Maple-specific)
+ 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)
+ }
+
+ 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
+--------
+
+- :ref:`Maple PWM tutorial <pwm>`
diff --git a/source/wirish/types.rst b/source/wirish/types.rst
new file mode 100644
index 0000000..0b78d01
--- /dev/null
+++ b/source/wirish/types.rst
@@ -0,0 +1,6 @@
+.. _wirish-types:
+
+Standard types
+==============
+
+Stub. (uint8, uint64, etc.)