diff options
Diffstat (limited to 'docs/source/arduino')
23 files changed, 190 insertions, 149 deletions
diff --git a/docs/source/arduino/arithmetic.rst b/docs/source/arduino/arithmetic.rst index 412a0be..69cf166 100644 --- a/docs/source/arduino/arithmetic.rst +++ b/docs/source/arduino/arithmetic.rst @@ -14,7 +14,7 @@ Description These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, ``9 / 4`` gives ``2`` -since 9 and 4 are ints. +since 9 and 4 are :ref:`int variables <arduino-int>`. This also means that the operation can overflow if the result is larger than that which can be stored in the data type (e.g. adding 1 @@ -126,4 +126,4 @@ See Also - :ref:`sizeof <arduino-sizeof>`\ () -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bitwisemath.rst b/docs/source/arduino/bitwisemath.rst index 196cc2c..40c3d7a 100644 --- a/docs/source/arduino/bitwisemath.rst +++ b/docs/source/arduino/bitwisemath.rst @@ -120,7 +120,7 @@ program to blink digital pin 13 (the LED pin on Maple):: void setup(){ pinMode(led_pin, OUTPUT); } - + void loop(){ toggle = toggle ^ 1; digitalWrite(led_pin, toggle); @@ -183,4 +183,4 @@ See Also ``|=``, ``^=``). -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/boolean.rst b/docs/source/arduino/boolean.rst index 8106520..1d834d3 100644 --- a/docs/source/arduino/boolean.rst +++ b/docs/source/arduino/boolean.rst @@ -6,7 +6,8 @@ Boolean Operators ================= These can be used inside the condition of an :ref:`if <arduino-if>` -statement. +statement. Evaluate to :ref:`true <arduino-constants-true>` or +:ref:`false <arduino-constants-false>`. .. contents:: Contents :local: @@ -45,6 +46,7 @@ True if either operand is true. For example:: is true if either ``x`` or ``y`` is greater than 0. +.. _arduino-boolean-not: ! (logical not) --------------- @@ -55,7 +57,7 @@ True if the operand is false. For example:: // ... } -is true if ``x`` is false (i.e. if ``x`` equals zero). +is true if ``x`` is false (i.e. if ``x`` is zero). Some Advice ----------- @@ -86,4 +88,4 @@ See Also - :ref:`if statement <arduino-if>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/braces.rst b/docs/source/arduino/braces.rst index 38018fe..04518b3 100644 --- a/docs/source/arduino/braces.rst +++ b/docs/source/arduino/braces.rst @@ -59,10 +59,10 @@ pages for more information):: while (boolean expression) { // code inside the loop goes here } - + for (initialisation; termination condition; incrementing expr) { // code inside the loop goes here - } + } do { // code inside the loop goes here @@ -80,7 +80,7 @@ reference page for more information):: } else if (boolean expression) { // code inside the "else if" - } + } else { // code inside the "else" } @@ -94,4 +94,4 @@ reference page for more information):: out. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/break.rst b/docs/source/arduino/break.rst index 8c0478a..3e1e9ee 100644 --- a/docs/source/arduino/break.rst +++ b/docs/source/arduino/break.rst @@ -19,17 +19,17 @@ Example for (x = 0; x < 255; x ++) { digitalWrite(PWMpin, x); - sens = analogRead(sensorPin); + sens = analogRead(sensorPin); if (sens > threshold){ // bail out on sensor detect x = 0; // this line of code means that we'll immediately exit // from the "for" loop: break; - } + } delay(50); } - -.. include:: cc-attribution.txt
\ No newline at end of file + +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/bytecast.rst b/docs/source/arduino/bytecast.rst index 38aec36..348c9fb 100644 --- a/docs/source/arduino/bytecast.rst +++ b/docs/source/arduino/bytecast.rst @@ -10,17 +10,17 @@ Description Converts a value to the :ref:`byte <arduino-byte>` data type. -.. warning:: +.. note:: Casting to the byte type is provided for compatibility with - Arduino. However, ``byte`` is a non-standard type. The standard - C++ type for storing an 8-bit unsigned integer is ``unsigned - char``, and we recommend using that instead. + Arduino. However, the recommended Maple type for storing an 8-bit + unsigned integer is ``uint8``. (C and C++ programmers: ``stdint.h`` + is also available). - In order to cast a variable ``x`` to an ``unsigned char``, the + In order to cast a variable ``x`` to a ``uint8``, the following syntax can be used:: - (unsigned char)(x); + uint8(x); Syntax ------ @@ -50,4 +50,4 @@ See Also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/comments.rst b/docs/source/arduino/comments.rst index e46fc48..b50aa0f 100644 --- a/docs/source/arduino/comments.rst +++ b/docs/source/arduino/comments.rst @@ -14,19 +14,23 @@ One use for comments is to help you understand (or remember) how your program works, or to inform others how your program works. There are two different ways of making comments. +.. _arduino-comments-singleline: + **Single line comment**: Anything following two slashes, ``//``, until the end of the line, is a comment:: x = 5; // the rest of this line is a comment +.. _arduino-comments-multiline: + **Multi-line comment**: Anything in between a pair of ``/*`` and ``*/`` is a comment:: - + /* <-- a slash-star begins a multi-line comment all of this in the multi-line comment - you can use it to comment out whole blocks of code - + if (gwb == 0){ // single line comment is OK inside a multi-line comment x = 3; } @@ -60,4 +64,4 @@ is cryptic or unhelpful. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/const.rst b/docs/source/arduino/const.rst index eb2b07b..b008144 100644 --- a/docs/source/arduino/const.rst +++ b/docs/source/arduino/const.rst @@ -26,13 +26,13 @@ Example // this defines a variable called "pi", which cannot be changed: const float pi = 3.14; float x; - + // .... - + x = pi * 2; // it's fine to find the value of a const variable - + pi = 7; // illegal - you can't write to (modify) a constant - + **#define** or **const** ------------------------ @@ -49,4 +49,4 @@ See Also - :ref:`volatile <arduino-volatile>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/constants.rst b/docs/source/arduino/constants.rst index 3a819b3..e841c9b 100644 --- a/docs/source/arduino/constants.rst +++ b/docs/source/arduino/constants.rst @@ -103,7 +103,7 @@ Digital pins can be used either as **INPUT** or **OUTPUT**. Changing a pin from INPUT TO OUTPUT with pinMode() drastically changes the electrical behavior of the pin. - +.. _arduino-constants-input: Pins Configured as Inputs ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -115,7 +115,7 @@ circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This makes them useful for reading a sensor, but not powering an LED. - +.. _arduino-constants-output: Pins Configured as Outputs ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -132,7 +132,7 @@ of current provided by an Atmega pin is also not enough to power most relays or motors, and some interface circuitry will be required. -.. _arduino-fpconstants: +.. _arduino-constants-fp: Floating-Point Constants ------------------------ @@ -141,28 +141,26 @@ Similar to integer constants, floating point constants are used to make code more readable. Floating point constants are swapped at compile time for the value to which the expression evaluates. +.. TODO explain that floating point literals are doubles +.. _arduino-constants-fp-f: -Examples: - +.. TODO f modifiers +Examples: ``n = .005;`` - - Floating point constants can also be expressed in a variety of scientific notation. 'E' and 'e' are both accepted as valid exponent indicators. - - :: - + floating-point evaluates to: also evaluates to: - constant - + constant + 10.0 10 2.34E5 2.34 * 10^5 234000 67e-12 67.0 * 10^-12 .000000000067 @@ -301,4 +299,4 @@ See also - `unsigned long <http://arduino.cc/en/Reference/UnsignedLong>`_ -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/continue.rst b/docs/source/arduino/continue.rst index 31af3a5..bda1c95 100644 --- a/docs/source/arduino/continue.rst +++ b/docs/source/arduino/continue.rst @@ -2,8 +2,9 @@ .. _arduino-continue: -continue -======== +========== + continue +========== The ``continue`` keyword skips the rest of the current iteration of a :ref:`while <arduino-while>`\ , :ref:`for <arduino-for>`\ , or @@ -13,22 +14,21 @@ iterations. Example -------- +======= :: - - for (x = 0; x < 255; x ++) - { - if (x > 40 && x < 120){ // create jump in values + + for (x = 0; x < 255; x ++) { + if (x > 40 && x < 120) { // create jump in values continue; // skips the next two lines and goes to the // beginning of the loop, with the next value of x } - + digitalWrite(PWMpin, x); delay(50); } -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/delaymicroseconds.rst b/docs/source/arduino/delaymicroseconds.rst index 10f3a1b..d1016f1 100644 --- a/docs/source/arduino/delaymicroseconds.rst +++ b/docs/source/arduino/delaymicroseconds.rst @@ -21,18 +21,18 @@ Example The following example configures pin number 8 to work as an output pin, and sends a train of pulses with a period of roughly 100 microseconds:: - + int outPin = 8; - + void setup() { pinMode(outPin, OUTPUT); // sets the digital pin as output } - + void loop() { digitalWrite(outPin, HIGH); // sets the pin on - delayMicroseconds(50); // pauses for 50 microseconds + delayMicroseconds(50); // pauses for 50 microseconds digitalWrite(outPin, LOW); // sets the pin off - delayMicroseconds(50); // pauses for 50 microseconds + delayMicroseconds(50); // pauses for 50 microseconds } @@ -62,4 +62,4 @@ See Also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/floatcast.rst b/docs/source/arduino/floatcast.rst index 6a2e799..a8d1113 100644 --- a/docs/source/arduino/floatcast.rst +++ b/docs/source/arduino/floatcast.rst @@ -9,13 +9,14 @@ Description ----------- Converts a value to the :ref:`float <arduino-float>` data type. Here -is an example:: +is an example (see the :ref:`constants reference +<arduino-constants-fp-f>` for an explanation of the "2.0f"):: int x = 2; - float f = float(x); // f now holds "2.0", a floating point value + float f = float(x); // f now holds 2.0f, a float value The value ``x`` can be of any type. However, if ``x`` is not a number -(like an ``int`` or ``long``), you will get strange results. +(like an ``int``), you will get strange results. See the :ref:`float <arduino-float>` reference for details about the precision and limitations of ``float`` values on the Maple. @@ -24,6 +25,7 @@ See Also -------- - :ref:`float <arduino-float>` +- :ref:`double <arduino-double>` +- :ref:`double() <arduino-doublecast>` - -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/goto.rst b/docs/source/arduino/goto.rst index e683c98..2901913 100644 --- a/docs/source/arduino/goto.rst +++ b/docs/source/arduino/goto.rst @@ -95,7 +95,7 @@ Here's an example:: if (analogRead(0) > 250) { goto bailout; } - // more statements ... + // more statements ... } // innermost loop ends here } @@ -127,4 +127,4 @@ See Also - Knuth, Donald. `Structured Programming with go to Statements <http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf>`_ (PDF) -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/highbyte.rst b/docs/source/arduino/highbyte.rst index 74717c1..5b1c24e 100644 --- a/docs/source/arduino/highbyte.rst +++ b/docs/source/arduino/highbyte.rst @@ -6,9 +6,9 @@ highByte(x) .. warning:: This macro is provided for compatibility with Arduino only. It returns the second-least significant byte in an integral value. It makes sense to call this the "high" byte on a 16-bit - microcontroller like the Atmel chips on Arduinos, but it makes no - sense at all on a 32-bit microcontroller like the STM32s in the - Maple line. + ``int`` microcontroller like the Atmel chips on Arduinos, but it + makes no sense at all on a 32-bit microcontroller like the STM32s + in the Maple line. In short: we provide this so that existing Arduino code works as expected, but **strongly discourage its use** in new programs. @@ -50,4 +50,4 @@ See Also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/millis.rst b/docs/source/arduino/millis.rst index 12f5d8d..f52d396 100644 --- a/docs/source/arduino/millis.rst +++ b/docs/source/arduino/millis.rst @@ -32,7 +32,7 @@ Example :: unsigned long time; - + void setup(){ Serial.begin(9600); } @@ -67,4 +67,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/setup.rst b/docs/source/arduino/setup.rst index 79c9527..9cc96d4 100644 --- a/docs/source/arduino/setup.rst +++ b/docs/source/arduino/setup.rst @@ -15,15 +15,15 @@ Example :: - + int buttonPin = 3; - + void setup() { Serial.begin(9600); pinMode(buttonPin, INPUT); } - + void loop() { // ... @@ -31,4 +31,4 @@ Example -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/sizeof.rst b/docs/source/arduino/sizeof.rst index 8513e9d..7c31809 100644 --- a/docs/source/arduino/sizeof.rst +++ b/docs/source/arduino/sizeof.rst @@ -5,28 +5,20 @@ sizeof() ======== -Syntax ------- +The ``sizeof`` operator on the Maple returns the number of bytes +needed to store a value of a given type\ [#fcharsize]_. This can be +an ordinary numeric type, like ``int``. It can be something more +complicated, like a ``struct`` or ``union``. If the argument to +``sizeof`` is an array, it returns the total number of bytes occupied +by the array. -:: +The general syntax looks like this:: sizeof(type) sizeof(var) - - -Description ------------ - -The ``sizeof`` operator returns the number of bytes needed to store a -value of a given type. This can be an ordinary numeric type, like -``int``. It can be something more complicated, like a ``struct`` or -``union``. If the argument to ``sizeof`` is an array, it returns the -total number of bytes occupied by the array. - - -Examplec --------- +Example +------- The ``sizeof`` operator is useful for dealing with arrays (such as strings) where it is convenient to be able to change the size of the @@ -51,15 +43,22 @@ changing the text phrase:: } -Note that ``sizeof`` returns the total number of bytes; this is equal -to the number of ``char``\ s only because the C++ standard guarantees -that ``sizeof(char) == 1``. So for larger variable types such as -``int``, the :ref:`for loop <arduino-for>` would look something like -this:: +Note that ``sizeof`` returns the total number of bytes. So for larger +variable types such as ``int``, the :ref:`for loop <arduino-for>` +would look something like this:: for (i = 0; i < (sizeof(myInts)/sizeof(int)) - 1; i++) { // do something with myInts[i] } +.. rubric:: Footnotes + +.. [#fcharsize] Technically (and pedantically) speaking, ``sizeof`` + returns a multiple of the number of bits a ``char`` occupies in + memory. However, on the Maple (this goes for most C++ + implementations), a ``char`` occupies 8 bits = 1 byte. All the C++ + standard guarantees, however, is that a ``char`` occupies at + *least* 8 bits. + +.. include:: cc-attribution.txt -.. include:: cc-attribution.txt
\ No newline at end of file diff --git a/docs/source/arduino/static.rst b/docs/source/arduino/static.rst index 76bf949..01f3dbf 100644 --- a/docs/source/arduino/static.rst +++ b/docs/source/arduino/static.rst @@ -15,8 +15,8 @@ Variables declared as ``static`` will only be created and initialized the first time a function is called. .. note:: This is only one use of the ``static`` keyword in C++. It - has some other important uses that are outside the scope of this - documentation; consult a reliable C++ reference for details. + has some other important uses that are not documented here; consult + a reliable C++ reference for details. Example ------- @@ -54,4 +54,4 @@ it was declared ``static``. Thus, ``numSensorReadings`` is a count of the number of times that ``readSensors()`` has been called. -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/switchcase.rst b/docs/source/arduino/switchcase.rst index 2ca2793..9f66d0a 100644 --- a/docs/source/arduino/switchcase.rst +++ b/docs/source/arduino/switchcase.rst @@ -1,3 +1,5 @@ +.. highlight:: cpp + .. _arduino-switchcase: switch / case statements @@ -7,10 +9,7 @@ Like :ref:`if/else <arduino-else>` blocks, A ``switch`` statement controls program flow by allowing you to specify different code that should be executed under various cases. -Syntax ------- - -:: +The general syntax looks like this:: switch (var) { case val1: @@ -28,6 +27,7 @@ Where ``var`` is a variable whose value to investigate, and the ``val1``, ``val2`` after each ``case`` are constant values that ``var`` might be. + Description ----------- @@ -36,46 +36,82 @@ specified in ``case`` statements. When a ``case`` statement is found whose value matches that of the variable, the code in that case statement is run. -The ``break`` keyword exits the switch statement, and is typically -used at the end of each ``case``. Without a ``break``, the ``switch`` -statement will continue executing the following ``case`` expressions -("falling-through") until a ``break`` (or the end of the switch -statement) is reached. +Here's a more concrete example:: -Writing ``default:`` instead of a ``case`` statement allows you to -specify what to do if none of the ``case`` statements matches. Having -a ``default:`` is optional (you can leave it out), but if you have -one, it must appear after all of the ``case`` statements, as shown -above. + switch (var) { + case 1: + doThing1(); + break; + case 2: + doThing2(); + break; + } + afterTheSwitch(); -``switch`` statements are often used with an ``enum`` value as the -variable to compare. In this case, you can write down all of the -values the ``enum`` takes as ``case`` statements, and be sure you've -covered all the possibilities. +In the above example, if ``var == 1``, then the code beginning on the +line after ``case 1:`` gets executed. That is, if ``var`` is one, +``doThing1()`` gets called first, and then the ``break`` statement +gets executed. + +The ``break`` keyword exits the ``switch`` statement, and is typically +used at the end of each ``case``. Since there is a ``break`` at the +end of ``case 1:``, the ``switch`` statement gets exited, and the next +line to be run is the one which calls ``afterTheSwitch()``. + +Without a ``break``, the ``switch`` statement will continue executing +the following ``case`` expressions ("falling-through") until a +``break`` (or the end of the switch statement) is reached. Let's +pretend the ``switch`` looked like this instead:: -Example -------- + switch (var) { + case 1: + doThing1(); + // no break statement anymore + case 2: + doThing2(); + break; + } + afterTheSwitch(); + +Now, if ``var`` is one, ``doThing1()`` gets executed like before. +However, without a ``break``, the code would continue to be executed +line-by-line, so ``doThing2()`` would be called next. At this point, +a ``break`` has been reached, so the program continues by calling +``afterTheSwitch()``. This is usually not what you want, which is why +each ``case`` usually has a ``break`` at the end. -:: +Writing "``default:``" instead of a ``case`` statement allows you to +specify what to do if none of the ``case`` statements matches. Having +a ``default`` is optional (you can leave it out), but if you have one, +it must appear after all of the ``case`` statements. Let's add a +``default`` to the ``switch`` we've been discussing:: switch (var) { case 1: - //do something when var equals 1 + doThing1(); break; case 2: - //do something when var equals 2 + doThing2(); break; default: - // if nothing else matches, do the default - // default is optional + doSomethingElse(); } + afterTheSwitch(); -See also: ---------- - -`if...else <http://arduino.cc/en/Reference/Else>`_ +If ``var`` is one, then ``doThing1()`` gets called. If ``var`` is +two, ``doThing2()`` gets called. If ``var`` is anything else, +``doSomethingElse()`` gets called. As stated above, a ``default`` is +optional. If you're missing one and none of the ``case`` statements +match, the ``switch`` does nothing at all, as if it wasn't there. +``switch`` statements are often used with an ``enum`` value as the +variable to compare. In this case, you can write down all of the +values the ``enum`` takes as ``case`` statements, and be sure you've +covered all the possibilities. +See also: +--------- +- :ref:`if...else <arduino-else>` -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/unsignedchar.rst b/docs/source/arduino/unsignedchar.rst index 1fd7a1c..5c26d17 100644 --- a/docs/source/arduino/unsignedchar.rst +++ b/docs/source/arduino/unsignedchar.rst @@ -41,4 +41,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/variables.rst b/docs/source/arduino/variables.rst index bedb86b..0720041 100644 --- a/docs/source/arduino/variables.rst +++ b/docs/source/arduino/variables.rst @@ -9,7 +9,7 @@ A variable is a way of naming and storing a value for later use by the program, such as data from a sensor or an intermediate value used in a calculation. - +.. _arduino-variables-declaring: Declaring Variables ^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ store in choosing variable types. Variables will `roll over <#VariableRollover>`_ when the value stored exceeds the space assigned to store it. See below for an example. - +.. _arduino-variables-scope: Variable Scope ^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ influences how various functions in a program will *see* the variable. This is called variable `scope <http://arduino.cc/en/Reference/Scope>`_. - +.. _arduino-variables-initializing: Initializing Variables ^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ Example: int calibrationVal = 17; // declare calibrationVal and set initial value - +.. _arduino-variables-rollover: Variable Rollover ^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ variable on the left side. :: inputVariable1 = 7; // sets the variable named inputVariable1 to 7 - inputVariable2 = analogRead(2); // sets the variable named inputVariable2 to the + inputVariable2 = analogRead(2); // sets the variable named inputVariable2 to the // (digitized) input voltage read from analog pin #2 @@ -117,7 +117,7 @@ Examples int lightSensVal; char currentLetter; unsigned long speedOfLight = 186000UL; - char errorMessage = {"choose another option"}; // see string + char errorMessage = {"choose another option"}; // see string @@ -135,7 +135,7 @@ inputVariable2 which is a minimum of 100: { inputVariable2 = 100; } - + delay(inputVariable2); @@ -188,4 +188,4 @@ Variable Scope -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/void.rst b/docs/source/arduino/void.rst index 1d3bf8e..82f9606 100644 --- a/docs/source/arduino/void.rst +++ b/docs/source/arduino/void.rst @@ -16,17 +16,17 @@ Example: // actions are performed in the functions "setup" and "loop" // but no information is reported to the larger program - + void setup() { // ... } - + void loop() { // ... } - + @@ -37,4 +37,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt diff --git a/docs/source/arduino/volatile.rst b/docs/source/arduino/volatile.rst index 9516db0..fc02081 100644 --- a/docs/source/arduino/volatile.rst +++ b/docs/source/arduino/volatile.rst @@ -39,21 +39,21 @@ Example :: // toggles LED when interrupt pin changes state - + int pin = 13; volatile int state = LOW; - + void setup() { pinMode(pin, OUTPUT); attachInterrupt(0, blink, CHANGE); } - + void loop() { digitalWrite(pin, state); } - + void blink() { state = !state; @@ -70,4 +70,4 @@ See also -.. include:: cc-attribution.txt
\ No newline at end of file +.. include:: cc-attribution.txt |