diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-06-10 09:10:03 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-06-10 09:10:03 -0400 |
commit | 036c04bbe6c75f71a66fad90530ac1dec5e47b53 (patch) | |
tree | 38b1b0a8d57bb47389d3f79ef1b36a0a5789c165 /source | |
parent | a2f4a145b2349638cf68e03efa4553055bd50315 (diff) | |
download | librambutan-036c04bbe6c75f71a66fad90530ac1dec5e47b53.tar.gz librambutan-036c04bbe6c75f71a66fad90530ac1dec5e47b53.zip |
Docs: Use "BOARD_LED_PIN" instead of "13".
Fix examples where pin 13 was used explicitly instead of
BOARD_LED_PIN. Also change an AVR-specific example in
docs/lang/cpp/booleanvariables.rst to Maple conventions.
Diffstat (limited to 'source')
-rw-r--r-- | source/lang/api/delay.rst | 13 | ||||
-rw-r--r-- | source/lang/api/digitalwrite.rst | 7 | ||||
-rw-r--r-- | source/lang/cpp/bitwisemath.rst | 10 | ||||
-rw-r--r-- | source/lang/cpp/booleanvariables.rst | 19 | ||||
-rw-r--r-- | source/lang/cpp/define.rst | 6 | ||||
-rw-r--r-- | source/lang/cpp/if.rst | 14 | ||||
-rw-r--r-- | source/lang/cpp/int.rst | 4 | ||||
-rw-r--r-- | source/lang/cpp/unsignedint.rst | 4 |
8 files changed, 36 insertions, 41 deletions
diff --git a/source/lang/api/delay.rst b/source/lang/api/delay.rst index 9ef06a0..30bd436 100644 --- a/source/lang/api/delay.rst +++ b/source/lang/api/delay.rst @@ -42,17 +42,16 @@ Example :: - int ledPin = 13; // LED connected to pin 13 - void setup() { - pinMode(ledPin, OUTPUT); // sets the digital pin as output + // set up the built-in LED pin for output: + pinMode(BOARD_LED_PIN, OUTPUT); } void loop() { - digitalWrite(ledPin, HIGH); // sets the LED on - delay(1000); // waits for a second - digitalWrite(ledPin, LOW); // sets the LED off - delay(1000); // waits for a second + digitalWrite(BOARD_LED_PIN, HIGH); // sets the LED on + delay(1000); // waits for a second + digitalWrite(BOARD_LED_PIN, LOW); // sets the LED off + delay(1000); // waits for a second } .. _lang-delay-seealso: diff --git a/source/lang/api/digitalwrite.rst b/source/lang/api/digitalwrite.rst index 376cbc3..bae8db9 100644 --- a/source/lang/api/digitalwrite.rst +++ b/source/lang/api/digitalwrite.rst @@ -28,9 +28,10 @@ more slowly as an output than the other pins. Example ------- -The following example sets pin 13 to ``HIGH``, makes a one-second-long -delay, sets the pin back to ``LOW``, and delays again, causing a -blinking pattern (you could also use :ref:`lang-toggleled`):: +The following example sets the built-in LED pin to ``HIGH``, makes a +one-second-long delay, sets the pin back to ``LOW``, and delays again, +causing a blinking pattern (you could also use +:ref:`lang-toggleled`):: void setup() { pinMode(BOARD_LED_PIN, OUTPUT); // sets the digital pin as output diff --git a/source/lang/cpp/bitwisemath.rst b/source/lang/cpp/bitwisemath.rst index 59794ba..cfe34f2 100644 --- a/source/lang/cpp/bitwisemath.rst +++ b/source/lang/cpp/bitwisemath.rst @@ -109,21 +109,21 @@ The ^ operator is often used to toggle (i.e. change from 0 to 1, or 1 to 0) some of the bits in an integer expression. In a bitwise OR operation if there is a 1 in the mask bit, that bit is inverted; if there is a 0, the bit is not inverted and stays the same. Below is a -program to blink digital pin 13 (the LED pin on Maple):: +program to toggle the built-in LED pin (you can also accomplish this +with :ref:`lang-toggleled`):: - // Blink Maple LED pin + // Toggle built-in LED pin - int led_pin = 13; int toggle = 0; // demo for Exclusive OR void setup(){ - pinMode(led_pin, OUTPUT); + pinMode(BOARD_LED_PIN, OUTPUT); } void loop(){ toggle = toggle ^ 1; - digitalWrite(led_pin, toggle); + digitalWrite(BOARD_LED_PIN, toggle); delay(100); } diff --git a/source/lang/cpp/booleanvariables.rst b/source/lang/cpp/booleanvariables.rst index 0d76a12..e032c74 100644 --- a/source/lang/cpp/booleanvariables.rst +++ b/source/lang/cpp/booleanvariables.rst @@ -21,25 +21,20 @@ Example :: - int ledPin = 13; // LED on pin 13 - int switchPin = 12; // momentary switch on 12, other side connected to ground - // running is a boolean variable: bool running = false; void setup() { - pinMode(ledPin, OUTPUT); - pinMode(switchPin, INPUT); - digitalWrite(switchPin, HIGH); // turn on pullup resistor + pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(BOARD_BUTTON_PIN, INPUT); } void loop() { - if (digitalRead(switchPin) == LOW) { - // switch is pressed - pullup keeps pin high normally - delay(100); // delay to debounce switch - running = !running; // toggle running variable - digitalWrite(ledPin, running) // indicate via LED - } + if (isButtonPressed()) { + // button is pressed + running = !running; // toggle running variable + digitalWrite(BOARD_LED_PIN, running) // indicate via LED + } } See Also diff --git a/source/lang/cpp/define.rst b/source/lang/cpp/define.rst index bdf7283..b22085f 100644 --- a/source/lang/cpp/define.rst +++ b/source/lang/cpp/define.rst @@ -43,9 +43,9 @@ Example :: - #define LED_PIN 13 - // The compiler will replace any mention of LED_PIN with - // the value 3 at compile time. + #define MAPLE_LED_PIN 13 + // The compiler will replace any mention of MAPLE_LED_PIN with + // the value 13 at compile time. See Also -------- diff --git a/source/lang/cpp/if.rst b/source/lang/cpp/if.rst index d57b9f1..f248b05 100644 --- a/source/lang/cpp/if.rst +++ b/source/lang/cpp/if.rst @@ -43,28 +43,28 @@ conditional. If this is done, the next line (which ends in a semicolon) becomes the only line in the body. The following three ``if`` statements all do the same thing:: - if (x > 120) digitalWrite(ledPin, HIGH); + if (x > 120) digitalWrite(pin, HIGH); if (x > 120) - digitalWrite(ledPin, HIGH); + digitalWrite(pin, HIGH); if (x > 120) { - digitalWrite(ledPin, HIGH); + digitalWrite(pin, HIGH); } However, the following two examples are different:: // example 1: two lines of code in the if body if (x > 120) { - digitalWrite(ledPin1, HIGH); - digitalWrite(ledPin2, HIGH); + digitalWrite(pin1, HIGH); + digitalWrite(pin2, HIGH); } // example 2: one line of code in the if body, and // another line of code after the if statement if (x > 120) - digitalWrite(ledPin1, HIGH); // this is in the if body - digitalWrite(ledPin2, HIGH); // this is NOT in the if body + digitalWrite(pin1, HIGH); // this is in the if body + digitalWrite(pin2, HIGH); // this is NOT in the if body In the first example, since the body is enclosed in curly braces, both lines are included. In the second example, since the curly braces are diff --git a/source/lang/cpp/int.rst b/source/lang/cpp/int.rst index 3e96b69..fa63946 100644 --- a/source/lang/cpp/int.rst +++ b/source/lang/cpp/int.rst @@ -28,10 +28,10 @@ dealing with the :ref:`bitshift right operator (>>) The ``long`` type is a synonym for ``int``. -Here is an example of declaring an ``int`` variable named ``ledPin``, +Here is an example of declaring an ``int`` variable named ``pin``, then giving it value 13:: - int ledPin = 13; + int pin = 13; The general syntax for declaring an ``int`` variable named ``var``, then giving it value ``val``, looks like:: diff --git a/source/lang/cpp/unsignedint.rst b/source/lang/cpp/unsignedint.rst index b7d9716..f8ea473 100644 --- a/source/lang/cpp/unsignedint.rst +++ b/source/lang/cpp/unsignedint.rst @@ -36,9 +36,9 @@ that an ``unsigned int`` will "underflow" at 0, and "overflow" at The ``unsigned long`` type is a synonym for ``unsigned int``. Here is an example of declaring an ``unsigned int`` variable named -``ledPin``, then giving it value 13:: +``pin``, then giving it value 13:: - unsigned int ledPin = 13; + unsigned int pin = 13; The general syntax for declaring an ``unsigned int`` variable named ``var``, then giving it value ``val``, looks like:: |