From f77108922493b9b234fe8fa3413f278763eea008 Mon Sep 17 00:00:00 2001 From: Arnold <48472227+Arnold-n@users.noreply.github.com> Date: Sat, 31 Aug 2019 19:00:28 +0200 Subject: [PATCH 001/184] Update millis.adoc Use of millis() may become unreliable if timer0 is reprogrammed, so a small warning might be useful that timer0 is used by millis(). --- Language/Functions/Time/millis.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Time/millis.adoc b/Language/Functions/Time/millis.adoc index d031efded..dbc70ff54 100644 --- a/Language/Functions/Time/millis.adoc +++ b/Language/Functions/Time/millis.adoc @@ -64,7 +64,7 @@ void loop() { [float] === Notes and Warnings -Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. +Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. millis() uses timer0's overflow interrupt. -- // HOW TO USE SECTION ENDS From c1d6af8470f1d61dd7bb43dfb990be36bf919702 Mon Sep 17 00:00:00 2001 From: katerss1 <44533145+katerss1@users.noreply.github.com> Date: Sun, 22 Sep 2019 21:44:03 +0200 Subject: [PATCH 002/184] Fixed mistake You need to call pinMode() before calling analogWrite(); --- Language/Functions/Analog IO/analogWrite.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 28daf1085..f90825358 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -36,7 +36,7 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C [%hardbreaks] -You do not need to call `pinMode()` to set the pin as an output before calling `analogWrite()`. +You do need to call `pinMode()` to set the pin as an output before calling `analogWrite()`. The `analogWrite` function has nothing to do with the analog pins or the `analogRead` function. [%hardbreaks] From 0650027f260782b4cbf0e1f859c769968d22cd56 Mon Sep 17 00:00:00 2001 From: "Simon A. Eugster" Date: Sun, 1 Dec 2019 09:27:43 +0100 Subject: [PATCH 003/184] Update volatile.adoc: Add explanation to examples This change also adds a visual separator between the two code blocks so it is clear that they do not belong together. --- Language/Variables/Variable Scope & Qualifiers/volatile.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Language/Variables/Variable Scope & Qualifiers/volatile.adoc b/Language/Variables/Variable Scope & Qualifiers/volatile.adoc index 20fbd6fbd..19a699bda 100644 --- a/Language/Variables/Variable Scope & Qualifiers/volatile.adoc +++ b/Language/Variables/Variable Scope & Qualifiers/volatile.adoc @@ -55,6 +55,7 @@ There are several ways to do this: === Example Code // Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄ +Use a `volatile byte` to store the pin state in a single byte: [source,arduino] ---- @@ -77,16 +78,19 @@ void blink() { } ---- +Use an atomic block for atomic access to a 16-bit `int`: [source,arduino] ---- #include // this library includes the ATOMIC_BLOCK macro. volatile int input_from_interrupt; +void loop() { ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { // code with interrupts blocked (consecutive atomic operations will not get interrupted) int result = input_from_interrupt; } +} ---- From a239a516dd99bfdc6ab185604ac012443a82972e Mon Sep 17 00:00:00 2001 From: "Simon A. Eugster" Date: Sun, 8 Dec 2019 11:51:34 +0100 Subject: [PATCH 004/184] Update volatile.adoc: Add new code sample --- .../Variable Scope & Qualifiers/volatile.adoc | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Language/Variables/Variable Scope & Qualifiers/volatile.adoc b/Language/Variables/Variable Scope & Qualifiers/volatile.adoc index 19a699bda..ecf5a5544 100644 --- a/Language/Variables/Variable Scope & Qualifiers/volatile.adoc +++ b/Language/Variables/Variable Scope & Qualifiers/volatile.adoc @@ -55,42 +55,52 @@ There are several ways to do this: === Example Code // Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄ -Use a `volatile byte` to store the pin state in a single byte: +The `volatile` modifier ensures that changes to the `state` variable are immediately visible in `loop()`. Without the `volatile` modifier, the `state` variable would be loaded into a register when entering the function and would not be updated anymore until the function ends. [source,arduino] ---- -// toggles LED when interrupt pin changes state +// Flashes the LED for 1 s if the input has changed +// in the previous second. -int pin = 13; volatile byte state = LOW; void setup() { - pinMode(pin, OUTPUT); - attachInterrupt(digitalPinToInterrupt(2), blink, CHANGE); + pinMode(LED_BUILTIN, OUTPUT); + attachInterrupt(digitalPinToInterrupt(2), toggle, CHANGE); } void loop() { - digitalWrite(pin, state); + bool changedInTheMeantime = false; + + byte originalState = state; + delay(1000); + byte newState = state; + + if (newState != originalState) { + // toggle() has been called during delay(1000) + changedInTheMeantime = true; + } + + digitalWrite(LED_BUILTIN, changedInTheMeantime ? HIGH : LOW); } -void blink() { +void toggle() { state = !state; } ---- -Use an atomic block for atomic access to a 16-bit `int`: +To access a variable with size greater than the microcontroller’s 8-bit data bus, use the `ATOMIC_BLOCK` macro. The macro ensures that the variable is read in an atomic operation, i.e. its contents cannot be altered while it is being read. [source,arduino] ---- #include // this library includes the ATOMIC_BLOCK macro. volatile int input_from_interrupt; -void loop() { +// Somewhere in the code, e.g. inside loop() ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { // code with interrupts blocked (consecutive atomic operations will not get interrupted) int result = input_from_interrupt; } -} ---- From a6d6081ee6368250921ec7e44ffa63a3a10bc4d5 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 1 Jan 2020 02:39:27 -0800 Subject: [PATCH 005/184] Document PWM pins of Nano Every/33 IoT/BLE/BLE Sense I had to remove the integer literal representations of the An pins because they caused the Nano 33 IoT row to be excessively long. It's no loss because people should always use the An pin names anyway. --- Language/Functions/Analog IO/analogWrite.adoc | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 28daf1085..95402cba0 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -19,19 +19,21 @@ subCategories: [ "Analog I/O" ] === Description Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to `analogWrite()`, the pin will generate a steady rectangular wave of the specified duty cycle until the next call to `analogWrite()` (or a call to `digitalRead()` or `digitalWrite()`) on the same pin. [options="header"] -|==================================================================================================== -| Board | PWM Pins | PWM Frequency -| Uno, Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) -| Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) -| Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) -| Uno WiFi Rev.2 | 3, 5, 6, 9, 10 | 976 Hz -| MKR boards * | 0 - 8, 10, A3 (18), A4 (19) | 732 Hz -| MKR1000 WiFi * | 0 - 8, 10, 11, A3 (18), A4 (19) | 732 Hz -| Zero * | 3 - 13, A0 (14), A1 (15) | 732 Hz -| Due ** | 2-13 | 1000 Hz -| 101 | 3, 5, 6, 9 | pins 3 and 9: 490 Hz, pins 5 and 6: 980 Hz -|==================================================================================================== -{empty}* In addition to PWM capabilities on the pins noted above, the MKR and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + +|======================================================================================================== +| Board | PWM Pins | PWM Frequency +| Uno, Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) +| Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) +| Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) +| Uno WiFi Rev2, Nano Every | 3, 5, 6, 9, 10 | 976 Hz +| MKR boards * | 0 - 8, 10, A3, A4 | 732 Hz +| MKR1000 WiFi * | 0 - 8, 10, 11, A3, A4 | 732 Hz +| Zero * | 3 - 13, A0, A1 | 732 Hz +| Nano 33 IoT * | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz +| Nano 33 BLE/BLE Sense | 1 - 13, A0 - A7 | 500 Hz +| Due ** | 2-13 | 1000 Hz +| 101 | 3, 5, 6, 9 | pins 3 and 9: 490 Hz, pins 5 and 6: 980 Hz +|======================================================================================================== +{empty}* In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + {empty}** In addition to PWM capabilities on the pins noted above, the Due has true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. [%hardbreaks] From fff3f9e9adfd56be6eaf2eb4b60dd142bbd70a79 Mon Sep 17 00:00:00 2001 From: Rajat Shinde Date: Mon, 27 Apr 2020 01:49:37 +0530 Subject: [PATCH 006/184] Update define.adoc --- Language/Structure/Further Syntax/define.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Language/Structure/Further Syntax/define.adoc b/Language/Structure/Further Syntax/define.adoc index 561a6d7e8..78ad5676d 100644 --- a/Language/Structure/Further Syntax/define.adoc +++ b/Language/Structure/Further Syntax/define.adoc @@ -24,7 +24,7 @@ subCategories: [ "Further Syntax" ] This can have some unwanted side effects though, if for example, a constant name that had been #defined is included in some other constant or variable name. In that case the text would be replaced by the #defined number (or text). [%hardbreaks] -In general, the `link:../../../variables/variable-scope\--qualifiers/const[const]` keyword is preferred for defining constants and should be used instead of `#define`. +In general, the `link:../../variables/variable-scope-qualifiers/const[const]` keyword is preferred for defining constants and should be used instead of `#define`. [%hardbreaks] [float] @@ -88,8 +88,8 @@ Similarly, including an equal sign after the #define statement will also generat === See also [role="language"] -* #LANGUAGE# link:../../../variables/variable-scope\--qualifiers/const[const] -* #LANGUAGE# link:../../../variables/constants/constants[Constants] +* #LANGUAGE# link:../../variables/variable-scope-qualifiers/const[const] +* #LANGUAGE# link:../../variables/constants/constants[Constants] -- // SEE ALSO SECTION ENDS From 6a20121c4fcd43f4f04d0d46fa12c08c2eb21da5 Mon Sep 17 00:00:00 2001 From: AndyDHill Date: Tue, 28 Apr 2020 22:45:54 +0100 Subject: [PATCH 007/184] Update pulseIn.adoc Ammendment that picked up that if the optional parameter is used code operates faster. --- Language/Functions/Advanced IO/pulseIn.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Language/Functions/Advanced IO/pulseIn.adoc b/Language/Functions/Advanced IO/pulseIn.adoc index 964cb7a4f..1a34dc93e 100644 --- a/Language/Functions/Advanced IO/pulseIn.adoc +++ b/Language/Functions/Advanced IO/pulseIn.adoc @@ -20,6 +20,8 @@ subCategories: [ "Advanced I/O" ] Reads a pulse (either `HIGH` or `LOW`) on a pin. For example, if `value` is `HIGH`, `pulseIn()` waits for the pin to go from `LOW` to `HIGH`, starts timing, then waits for the pin to go `LOW` and stops timing. Returns the length of the pulse in microseconds or gives up and returns 0 if no complete pulse was received within the timeout. The timing of this function has been determined empirically and will probably show errors in longer pulses. Works on pulses from 10 microseconds to 3 minutes in length. + +NOTE: if the optional timeout is used code will execute faster. [%hardbreaks] From 341f158cb63a36fb3f6ebf34db1124369d23d09f Mon Sep 17 00:00:00 2001 From: Ashutosh Pandey Date: Tue, 23 Jun 2020 19:06:56 +0530 Subject: [PATCH 008/184] Added Example Code/ Notes and warnings There was no example code given, and the returns section was incorrect. The code was tested on Arduino Mega 2560. --- .../Functions/Bits and Bytes/bitClear.adoc | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Bits and Bytes/bitClear.adoc b/Language/Functions/Bits and Bytes/bitClear.adoc index c81e359fe..ded704cf5 100644 --- a/Language/Functions/Bits and Bytes/bitClear.adoc +++ b/Language/Functions/Bits and Bytes/bitClear.adoc @@ -34,7 +34,7 @@ Clears (writes a 0 to) a bit of a numeric variable. [float] === Returns -Nothing +`x`: the value of the numeric variable after the bit at position `n` is cleared. -- // OVERVIEW SECTION ENDS @@ -45,6 +45,32 @@ Nothing -- [float] +=== Example Code +// Describe what the example code is all about and add relevant code +Prints the output of `bitClear(x,n)` on two given integers. The binary representation of 6 is 0110, so when `n=1`, the second bit from the right is set to 0. After this we are left with 0100 in binary, so 4 is returned. + +[source,arduino] +---- +void setup() +{ +Serial.begin(9600); +} + +void loop() +{ +int x = 6; int n = 1; //setting the value of x and n +Serial.print(bitClear(x,n)); //printing the output of the bitClear(x,n) +} +---- +[%hardbreaks] + +[float] +=== Notes and Warnings +The indexing of the rightmost bit starts from 0, so `n=1` clears the second bit from the right. If the bit at any given position is already zero, `x` is returned unchanged. + +Both `x` and `n` must be integers. + +-- === See also -- From c4a713be2b040457b4a0004adbe664ef96c87daa Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Mon, 13 Jul 2020 20:35:40 +0200 Subject: [PATCH 009/184] Add analogReference modes for the Arduino 33 BLE Found at https://github.com/arduino/ArduinoCore-mbed/blob/master/variants/ARDUINO_NANO33BLE/pins_arduino.h#L13 --- Language/Functions/Analog IO/analogReference.adoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Language/Functions/Analog IO/analogReference.adoc b/Language/Functions/Analog IO/analogReference.adoc index 31ae3d39c..4b6c97978 100644 --- a/Language/Functions/Analog IO/analogReference.adoc +++ b/Language/Functions/Analog IO/analogReference.adoc @@ -52,6 +52,13 @@ Arduino SAM Boards (Due) * AR_DEFAULT: the default analog reference of 3.3V. This is the only supported option for the Due. +Arduino mbed-enabled Boards (Nano 33 BLE only): only available when using the _Arduino mbed-enabled Boards_ platform, and not when using the _Arduino nRF528x Boards (Mbed OS)_ platform + +* AR_VDD: the default 3.3 V reference +* AR_INTERNAL: built-in 0.6 V reference +* AR_INTERNAL1V2: 1.2 V reference (internal 0.6 V reference with 2x gain) +* AR_INTERNAL2V4: 2.4 V reference (internal 0.6 V reference with 4x gain) + [%hardbreaks] From 309efcc052787c0e70af6d134823d609db401bf0 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 15 Jul 2020 05:53:01 -0700 Subject: [PATCH 010/184] Make markup valid The newly added content was placed inside the "See Also" section, which caused the generation process to fail: ERROR 2020/07/15 05:00:40 Language/Functions/Bits and Bytes/bitClear.adoc: asciidoctor: WARNING: : line 69: section title out of sequence: expected level 1, got level 2 ERROR 2020/07/15 05:00:40 Language/Functions/Bits and Bytes/bitClear.adoc: asciidoctor: WARNING: : line 71: unterminated open block --- Language/Functions/Bits and Bytes/bitClear.adoc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Bits and Bytes/bitClear.adoc b/Language/Functions/Bits and Bytes/bitClear.adoc index ded704cf5..ca7e9433f 100644 --- a/Language/Functions/Bits and Bytes/bitClear.adoc +++ b/Language/Functions/Bits and Bytes/bitClear.adoc @@ -40,8 +40,9 @@ Clears (writes a 0 to) a bit of a numeric variable. // OVERVIEW SECTION ENDS -// SEE ALSO SECTION -[#see_also] + +// HOW TO USE SECTION STARTS +[#howtouse] -- [float] @@ -67,10 +68,17 @@ Serial.print(bitClear(x,n)); //printing the output of the bitClear(x,n) [float] === Notes and Warnings The indexing of the rightmost bit starts from 0, so `n=1` clears the second bit from the right. If the bit at any given position is already zero, `x` is returned unchanged. +-- +// HOW TO USE SECTION ENDS + Both `x` and `n` must be integers. +// SEE ALSO SECTION +[#see_also] -- + +[float] === See also -- From 659c2928a4fb667718072be8694b96c44835cb38 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 15 Jul 2020 05:53:46 -0700 Subject: [PATCH 011/184] Standardize formatting of example code - Use the standard "Arduino sketch style" formatting. - Move the print to setup(), so it only happens once. --- Language/Functions/Bits and Bytes/bitClear.adoc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Language/Functions/Bits and Bytes/bitClear.adoc b/Language/Functions/Bits and Bytes/bitClear.adoc index ca7e9433f..b07259e44 100644 --- a/Language/Functions/Bits and Bytes/bitClear.adoc +++ b/Language/Functions/Bits and Bytes/bitClear.adoc @@ -52,15 +52,18 @@ Prints the output of `bitClear(x,n)` on two given integers. The binary represent [source,arduino] ---- -void setup() -{ -Serial.begin(9600); +void setup() { + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + int x = 6; + int n = 1; + Serial.print(bitClear(x, n)); // print the output of bitClear(x,n) } -void loop() -{ -int x = 6; int n = 1; //setting the value of x and n -Serial.print(bitClear(x,n)); //printing the output of the bitClear(x,n) +void loop() { } ---- [%hardbreaks] From 33656815efe05f5b770cc275b9b5ee1cb2820e67 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 15 Jul 2020 06:00:30 -0700 Subject: [PATCH 012/184] Remove "Notes and Warnings" section The zero-indexed nature of the macro is already documented in the parameters section. The handling of zeroed bits is already clear from the description. The requirement for the parameters to be integers seems fairly obvious to me, but I'm open to being convinced otherwise. However, if it is necessary to document the supported parameter types, that should be done in the parameters section, following the convention that has been established through the rest of the language reference content, so this part needs to be removed either way. --- Language/Functions/Bits and Bytes/bitClear.adoc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Language/Functions/Bits and Bytes/bitClear.adoc b/Language/Functions/Bits and Bytes/bitClear.adoc index b07259e44..7c8594c8f 100644 --- a/Language/Functions/Bits and Bytes/bitClear.adoc +++ b/Language/Functions/Bits and Bytes/bitClear.adoc @@ -68,14 +68,10 @@ void loop() { ---- [%hardbreaks] -[float] -=== Notes and Warnings -The indexing of the rightmost bit starts from 0, so `n=1` clears the second bit from the right. If the bit at any given position is already zero, `x` is returned unchanged. -- // HOW TO USE SECTION ENDS -Both `x` and `n` must be integers. // SEE ALSO SECTION [#see_also] From 4f0339886df9ef05ad1f5451facc9210d1ee8b9f Mon Sep 17 00:00:00 2001 From: Ethan Tracy <49354012+EthanTracy@users.noreply.github.com> Date: Mon, 20 Jul 2020 17:24:41 +1000 Subject: [PATCH 013/184] Update analogReference.adoc Fixed a typo on line 25 --- Language/Functions/Analog IO/analogReference.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogReference.adoc b/Language/Functions/Analog IO/analogReference.adoc index 4b6c97978..e0fd3aed6 100644 --- a/Language/Functions/Analog IO/analogReference.adoc +++ b/Language/Functions/Analog IO/analogReference.adoc @@ -22,7 +22,7 @@ Configures the reference voltage used for analog input (i.e. the value used as t Arduino AVR Boards (Uno, Mega, Leonardo, etc.) * DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards) -* INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328P and 2.56 volts on the ATmega32U4 and ATmega8 (not available on the Arduino Mega) +* INTERNAL: a built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328P and 2.56 volts on the ATmega32U4 and ATmega8 (not available on the Arduino Mega) * INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only) * INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only) * EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference. From 2e9dc6a72c93ef163d034eb920b07e9d9e5a128f Mon Sep 17 00:00:00 2001 From: Max Reynolds Date: Mon, 3 Aug 2020 09:37:39 +0100 Subject: [PATCH 014/184] Update link, currently noTone is 404. --- Language/Functions/Advanced IO/tone.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Advanced IO/tone.adoc b/Language/Functions/Advanced IO/tone.adoc index 56c65bbc5..86b4c1af6 100644 --- a/Language/Functions/Advanced IO/tone.adoc +++ b/Language/Functions/Advanced IO/tone.adoc @@ -17,7 +17,7 @@ subCategories: [ "Advanced I/O" ] [float] === Description -Generates a square wave of the specified frequency (and 50% duty cycle) on a pin. A duration can be specified, otherwise the wave continues until a call to link:../noTone[noTone()]. The pin can be connected to a piezo buzzer or other speaker to play tones. +Generates a square wave of the specified frequency (and 50% duty cycle) on a pin. A duration can be specified, otherwise the wave continues until a call to link:../notone[noTone()]. The pin can be connected to a piezo buzzer or other speaker to play tones. Only one tone can be generated at a time. If a tone is already playing on a different pin, the call to `tone()` will have no effect. If the tone is playing on the same pin, the call will set its frequency. @@ -72,6 +72,7 @@ If you want to play different pitches on multiple pins, you need to call `noTone [role="language"] * #LANGUAGE# link:../../analog-io/analogwrite[analogWrite()] +* #LANGUAGE# link:../notone[noTone()] [role="example"] From 68880c635b63635d6f0a5fc64fad3efcea2d269d Mon Sep 17 00:00:00 2001 From: Max Reynolds Date: Mon, 3 Aug 2020 11:44:27 +0100 Subject: [PATCH 015/184] Remove language link Co-authored-by: per1234 --- Language/Functions/Advanced IO/tone.adoc | 1 - 1 file changed, 1 deletion(-) diff --git a/Language/Functions/Advanced IO/tone.adoc b/Language/Functions/Advanced IO/tone.adoc index 86b4c1af6..41e3f5031 100644 --- a/Language/Functions/Advanced IO/tone.adoc +++ b/Language/Functions/Advanced IO/tone.adoc @@ -72,7 +72,6 @@ If you want to play different pitches on multiple pins, you need to call `noTone [role="language"] * #LANGUAGE# link:../../analog-io/analogwrite[analogWrite()] -* #LANGUAGE# link:../notone[noTone()] [role="example"] From 1d606277e0b0083f192b5722b24c8468db29fdc4 Mon Sep 17 00:00:00 2001 From: Nick Slocum Date: Mon, 17 Aug 2020 08:21:13 -0400 Subject: [PATCH 016/184] Fix link to "const" reference page. --- Language/Structure/Further Syntax/define.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Structure/Further Syntax/define.adoc b/Language/Structure/Further Syntax/define.adoc index 561a6d7e8..df3f8c455 100644 --- a/Language/Structure/Further Syntax/define.adoc +++ b/Language/Structure/Further Syntax/define.adoc @@ -88,7 +88,7 @@ Similarly, including an equal sign after the #define statement will also generat === See also [role="language"] -* #LANGUAGE# link:../../../variables/variable-scope\--qualifiers/const[const] +* #LANGUAGE# link:../../../variables/variable-scope-qualifiers/const[const] * #LANGUAGE# link:../../../variables/constants/constants[Constants] -- From 67d08023ee7ee4149c9458ae748361cbed1ef013 Mon Sep 17 00:00:00 2001 From: Rajat Shinde Date: Mon, 17 Aug 2020 19:55:41 +0530 Subject: [PATCH 017/184] Update define.adoc --- Language/Structure/Further Syntax/define.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Language/Structure/Further Syntax/define.adoc b/Language/Structure/Further Syntax/define.adoc index 78ad5676d..af9686072 100644 --- a/Language/Structure/Further Syntax/define.adoc +++ b/Language/Structure/Further Syntax/define.adoc @@ -24,7 +24,7 @@ subCategories: [ "Further Syntax" ] This can have some unwanted side effects though, if for example, a constant name that had been #defined is included in some other constant or variable name. In that case the text would be replaced by the #defined number (or text). [%hardbreaks] -In general, the `link:../../variables/variable-scope-qualifiers/const[const]` keyword is preferred for defining constants and should be used instead of `#define`. +In general, the `link:../../../variables/variable-scope-qualifiers/const[const]` keyword is preferred for defining constants and should be used instead of `#define`. [%hardbreaks] [float] @@ -88,8 +88,8 @@ Similarly, including an equal sign after the #define statement will also generat === See also [role="language"] -* #LANGUAGE# link:../../variables/variable-scope-qualifiers/const[const] -* #LANGUAGE# link:../../variables/constants/constants[Constants] +* #LANGUAGE# link:../../../variables/variable-scope\--qualifiers/const[const] +* #LANGUAGE# link:../../../variables/constants/constants[Constants] -- // SEE ALSO SECTION ENDS From 449988e80341efd3e0629cacd6b423e8fd346faa Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Tue, 18 Aug 2020 13:44:41 +0200 Subject: [PATCH 018/184] Update long.adoc Implemented changes from Issue 766 --- Language/Variables/Data Types/long.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Language/Variables/Data Types/long.adoc b/Language/Variables/Data Types/long.adoc index 061c9c2c9..82ed525d5 100644 --- a/Language/Variables/Data Types/long.adoc +++ b/Language/Variables/Data Types/long.adoc @@ -19,7 +19,7 @@ subCategories: [ "Data Types" ] === Description Long variables are extended size variables for number storage, and store 32 bits (4 bytes), from -2,147,483,648 to 2,147,483,647. -If doing math with integers, at least one of the numbers must be followed by an L, forcing it to be a long. See the link:../../constants/integerconstants[Integer Constants] page for details. +If doing math with integers at least one of the values must be of type long, either an integer constant followed by an L or a variable of type long, forcing it to be a long. See the link:../../constants/integerconstants[Integer Constants] page for details. [%hardbreaks] [float] @@ -28,7 +28,7 @@ If doing math with integers, at least one of the numbers must be followed by an [float] -=== Parameters +=== Description `var`: variable name. + `val`: the value assigned to the variable. @@ -49,7 +49,7 @@ If doing math with integers, at least one of the numbers must be followed by an [source,arduino] ---- -long speedOfLight = 186000L; // see the Integer Constants page for explanation of the 'L' +long speedOfLight_km_s = 300000L; // see the Integer Constants page for explanation of the 'L' ---- -- From 0be6243242f02bc9af28dd0a893167ea6cf156eb Mon Sep 17 00:00:00 2001 From: nor-easter Date: Wed, 19 Aug 2020 00:09:05 -0500 Subject: [PATCH 019/184] Update interrupts.adoc Correct function name: noInterrupts() --- Language/Functions/Interrupts/interrupts.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Interrupts/interrupts.adoc b/Language/Functions/Interrupts/interrupts.adoc index 251ecced8..2158aeed6 100644 --- a/Language/Functions/Interrupts/interrupts.adoc +++ b/Language/Functions/Interrupts/interrupts.adoc @@ -17,7 +17,7 @@ subCategories: [ "Interrupts" ] [float] === Description -Re-enables interrupts (after they've been disabled by link:../nointerrupts[nointerrupts()]. Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code. +Re-enables interrupts (after they've been disabled by link:../nointerrupts[noInterrupts()]. Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code. [%hardbreaks] From ba5358777797a8bbab330dedf71c767930bbb7b7 Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Wed, 19 Aug 2020 11:10:28 +0200 Subject: [PATCH 020/184] Update long.adoc Changed the Speed of light to referenced in Km/s instead of Miles/s. Reverted to Using "Parameters" instead of "description" for heading again. --- Language/Variables/Data Types/long.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/long.adoc b/Language/Variables/Data Types/long.adoc index 82ed525d5..07462b014 100644 --- a/Language/Variables/Data Types/long.adoc +++ b/Language/Variables/Data Types/long.adoc @@ -28,7 +28,7 @@ If doing math with integers at least one of the values must be of type long, eit [float] -=== Description +=== Parameters `var`: variable name. + `val`: the value assigned to the variable. From 1e3f412e763f5826b267aa1ec0f7e3e5e153a9e1 Mon Sep 17 00:00:00 2001 From: Jeremaiha-xmetix <67539861+Jeremaiha-xmetix@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:18:32 +0300 Subject: [PATCH 021/184] Misusage of `strlen_p()` There is no actual reason to put a method that counts characters inside a `for-loop`, such that every iteration will reevaluate the length of `signMessage`. --- Language/Variables/Utilities/PROGMEM.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Language/Variables/Utilities/PROGMEM.adoc b/Language/Variables/Utilities/PROGMEM.adoc index b483ad5fe..30993030a 100644 --- a/Language/Variables/Utilities/PROGMEM.adoc +++ b/Language/Variables/Utilities/PROGMEM.adoc @@ -86,7 +86,8 @@ void setup() { Serial.println(); // read back a char - for (byte k = 0; k < strlen_P(signMessage); k++) { + int signMessageLength = strlen_P(signMessage); + for (byte k = 0; k < signMessageLength; k++) { myChar = pgm_read_byte_near(signMessage + k); Serial.print(myChar); } From a37fe975ef1c92e89e2ec54f06e1eb546f7d77b1 Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Wed, 26 Aug 2020 12:34:30 +0200 Subject: [PATCH 022/184] Update constants.adoc Added missing word and corrected spelling --- Language/Variables/Constants/constants.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Constants/constants.adoc b/Language/Variables/Constants/constants.adoc index 6bbff458b..ad74c9f6d 100644 --- a/Language/Variables/Constants/constants.adoc +++ b/Language/Variables/Constants/constants.adoc @@ -44,7 +44,7 @@ The meaning of `HIGH` (in reference to a pin) is somewhat different depending on - a voltage greater than 2.0V volts is present at the pin (3.3V boards) [%hardbreaks] -A pin may also be configured as an INPUT with link:../../../functions/digital-io/pinmode[`pinMode()`], and subsequently made HIGH with `link:../../../functions/digital-io/digitalwrite[digitalWrite()]`. This will enable the internal 20K pullup resistors, which will _pull up_ the input pin to a `HIGH` reading unless it is pulled `LOW` by external circuitry. This can done alternatively by passing `INPUT_PULLUP` as argument to the link:../../../functions/digital-io/pinmode[`pinMode()`] funtion, as explained in more detail in the section "Defining Digital Pins modes: INPUT, INPUT_PULLUP, and OUTPUT" further below. +A pin may also be configured as an INPUT with link:../../../functions/digital-io/pinmode[`pinMode()`], and subsequently made HIGH with `link:../../../functions/digital-io/digitalwrite[digitalWrite()]`. This will enable the internal 20K pullup resistors, which will _pull up_ the input pin to a `HIGH` reading unless it is pulled `LOW` by external circuitry. This can be done alternatively by passing `INPUT_PULLUP` as argument to the link:../../../functions/digital-io/pinmode[`pinMode()`] function, as explained in more detail in the section "Defining Digital Pins modes: INPUT, INPUT_PULLUP, and OUTPUT" further below. [%hardbreaks] When a pin is configured to OUTPUT with link:../../../functions/digital-io/pinmode[`pinMode()`], and set to `HIGH` with link:../../../functions/digital-io/digitalwrite[`digitalWrite()`], the pin is at: From 2cde7a35cb86c2e284dfd8bf18b1ef3ff91ce951 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sat, 29 Aug 2020 10:29:35 -0700 Subject: [PATCH 023/184] Document double quotes syntax of #include directives --- Language/Structure/Further Syntax/include.adoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Language/Structure/Further Syntax/include.adoc b/Language/Structure/Further Syntax/include.adoc index e4020e65e..478a1ab28 100644 --- a/Language/Structure/Further Syntax/include.adoc +++ b/Language/Structure/Further Syntax/include.adoc @@ -27,6 +27,18 @@ The main reference page for AVR C libraries (AVR is a reference to the Atmel chi Note that `#include`, similar to `link:../define[#define]`, has no semicolon terminator, and the compiler will yield cryptic error messages if you add one. [%hardbreaks] + +[float] +=== Syntax +`#include ` + +`#include "LocalFile.h"` + + +[float] +=== Parameters +`LibraryFile.h`: when the angle brackets syntax is used, the libraries paths will be searched for the file. + +`LocalFile.h`: When the double quotes syntax is used, the folder of the file using the `#include` directive will be searched for the specified file, then the libraries paths if it was not found in the local path. Use this syntax for header files in the sketch's folder. + -- // OVERVIEW SECTION ENDS From 9a16bed58e50ff0a736ed188d768015854620e50 Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Mon, 7 Sep 2020 13:43:59 +0200 Subject: [PATCH 024/184] Revert "Update analogWrite doc" --- Language/Functions/Analog IO/analogWrite.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 1d01bd4c7..95402cba0 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -38,7 +38,7 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C [%hardbreaks] -You do need to call `pinMode()` to set the pin as an output before calling `analogWrite()`. +You do not need to call `pinMode()` to set the pin as an output before calling `analogWrite()`. The `analogWrite` function has nothing to do with the analog pins or the `analogRead` function. [%hardbreaks] From 34c5c0893f84ed41fea4640a9c05f4c67b034721 Mon Sep 17 00:00:00 2001 From: "Simon A. Eugster" Date: Wed, 23 Sep 2020 17:11:22 +0200 Subject: [PATCH 025/184] volatile.adoc: Add suggestions by @cmaglie --- .../Variable Scope & Qualifiers/volatile.adoc | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Language/Variables/Variable Scope & Qualifiers/volatile.adoc b/Language/Variables/Variable Scope & Qualifiers/volatile.adoc index ecf5a5544..79927f386 100644 --- a/Language/Variables/Variable Scope & Qualifiers/volatile.adoc +++ b/Language/Variables/Variable Scope & Qualifiers/volatile.adoc @@ -55,14 +55,14 @@ There are several ways to do this: === Example Code // Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄ -The `volatile` modifier ensures that changes to the `state` variable are immediately visible in `loop()`. Without the `volatile` modifier, the `state` variable would be loaded into a register when entering the function and would not be updated anymore until the function ends. +The `volatile` modifier ensures that changes to the `state` variable are immediately visible in `loop()`. Without the `volatile` modifier, the `state` variable may be loaded into a register when entering the function and would not be updated anymore until the function ends. [source,arduino] ---- // Flashes the LED for 1 s if the input has changed // in the previous second. -volatile byte state = LOW; +volatile byte changed = 0; void setup() { pinMode(LED_BUILTIN, OUTPUT); @@ -70,22 +70,21 @@ void setup() { } void loop() { - bool changedInTheMeantime = false; + if (changed == 1) { + // toggle() has been called from interrupts! - byte originalState = state; - delay(1000); - byte newState = state; + // Reset changed to 0 + changed = 0; - if (newState != originalState) { - // toggle() has been called during delay(1000) - changedInTheMeantime = true; + // Blink LED for 200 ms + digitalWrite(LED_BUILTIN, HIGH); + delay(200); + digitalWrite(LED_BUILTIN, LOW); } - - digitalWrite(LED_BUILTIN, changedInTheMeantime ? HIGH : LOW); } void toggle() { - state = !state; + changed = 1; } ---- From 3ef87e10bbb4ea32075b5ed66c13e07977326a92 Mon Sep 17 00:00:00 2001 From: MalcolmBoura Date: Wed, 30 Sep 2020 15:11:16 +0100 Subject: [PATCH 026/184] Update PROGMEM.adoc The strings have to be in flash whether they are loaded at start up (the default) or when needed. Hence using embed or the F macro should have no impact on the flash use. There is a very small time penalty, about 1 clock cycle per character + a function call I expect, but I don't know enough about how the Atmega works to be certain. --- Language/Variables/Utilities/PROGMEM.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Utilities/PROGMEM.adoc b/Language/Variables/Utilities/PROGMEM.adoc index b483ad5fe..de75ee608 100644 --- a/Language/Variables/Utilities/PROGMEM.adoc +++ b/Language/Variables/Utilities/PROGMEM.adoc @@ -187,7 +187,7 @@ When an instruction like : Serial.print("Write something on the Serial Monitor"); ---- -is used, the string to be printed is normally saved in RAM. If your sketch prints a lot of stuff on the Serial Monitor, you can easily fill the RAM. If you have free FLASH memory space, you can easily indicate that the string must be saved in FLASH using the syntax: +is used, the string to be printed is normally saved in RAM. If your sketch prints a lot of stuff on the Serial Monitor, you can easily fill the RAM. This can be avoided by not loading strings from the FLASH memory space until they are needed. You can easily indicate that the string is not to be copied to RAM at start up using the syntax: [source,arduino] ---- From 70a96ccd9693646bf322b47b72d15dacd5a3b033 Mon Sep 17 00:00:00 2001 From: TADefx <72205337+TADefx@users.noreply.github.com> Date: Thu, 1 Oct 2020 08:07:05 -0500 Subject: [PATCH 027/184] Update increment.adoc Corrected formatting of the Syntax section, caused by "+" operator that caused the "++" to be hidden and cut-off the lines --- Language/Structure/Compound Operators/increment.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Language/Structure/Compound Operators/increment.adoc b/Language/Structure/Compound Operators/increment.adoc index b9dd49b7b..66ec79ff6 100644 --- a/Language/Structure/Compound Operators/increment.adoc +++ b/Language/Structure/Compound Operators/increment.adoc @@ -24,8 +24,11 @@ Increments the value of a variable by 1. [float] === Syntax -`x++; // increment x by one and returns the old value of x` + -`++x; // increment x by one and returns the new value of x` +[source,arduino] +---- +x++; // increment x by one and returns the old value of x +++x; // increment x by one and returns the new value of x +---- [float] From 2eb7c1e8166f2fa685423e382079cba65c0edd37 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sat, 3 Oct 2020 08:46:27 -0700 Subject: [PATCH 028/184] Use {plus} predefined attribute to escape increment operator Previously, the increment operator in the syntax section was being treated as markup. --- Language/Structure/Compound Operators/increment.adoc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Language/Structure/Compound Operators/increment.adoc b/Language/Structure/Compound Operators/increment.adoc index 66ec79ff6..7419f1ff6 100644 --- a/Language/Structure/Compound Operators/increment.adoc +++ b/Language/Structure/Compound Operators/increment.adoc @@ -24,11 +24,8 @@ Increments the value of a variable by 1. [float] === Syntax -[source,arduino] ----- -x++; // increment x by one and returns the old value of x -++x; // increment x by one and returns the new value of x ----- +`x{plus}{plus}; // increment x by one and returns the old value of x` + +`{plus}{plus}x; // increment x by one and returns the new value of x` [float] From 6e02c42f9722b6a799ff41939342036a2a21be28 Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Sat, 10 Oct 2020 20:41:22 +0200 Subject: [PATCH 029/184] analogReference now supported by Arduino nRF528x In addition to the "Arduino mbed-enabled Boards" platform, this function is now also supported by the "Arduino nRF528x Boards (Mbed OS)" platform since version 1.1.6. https://github.com/arduino/ArduinoCore-nRF528x-mbedos/pull/81 --- Language/Functions/Analog IO/analogReference.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogReference.adoc b/Language/Functions/Analog IO/analogReference.adoc index e0fd3aed6..33cc8ad87 100644 --- a/Language/Functions/Analog IO/analogReference.adoc +++ b/Language/Functions/Analog IO/analogReference.adoc @@ -52,7 +52,7 @@ Arduino SAM Boards (Due) * AR_DEFAULT: the default analog reference of 3.3V. This is the only supported option for the Due. -Arduino mbed-enabled Boards (Nano 33 BLE only): only available when using the _Arduino mbed-enabled Boards_ platform, and not when using the _Arduino nRF528x Boards (Mbed OS)_ platform +Arduino mbed-enabled Boards (Nano 33 BLE only): available when using the _Arduino mbed-enabled Boards_ platform, or the _Arduino nRF528x Boards (Mbed OS)_ platform version 1.1.6 or later * AR_VDD: the default 3.3 V reference * AR_INTERNAL: built-in 0.6 V reference From b64c17fb541056fcc4769e03959f6fc0825a9b4c Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 24 Sep 2020 09:45:43 -0700 Subject: [PATCH 030/184] Document limitation of Serial1.begin() config value for Nano 33 BLE boards Add a warning that use of any Serial1.begin() config value other than SERIAL_8N1 on the Arduino Nano 33 BLE boards will cause an Mbed OS crash. --- Language/Functions/Communication/Serial/begin.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Language/Functions/Communication/Serial/begin.adoc b/Language/Functions/Communication/Serial/begin.adoc index f5701a75a..ea8c0f04e 100644 --- a/Language/Functions/Communication/Serial/begin.adoc +++ b/Language/Functions/Communication/Serial/begin.adoc @@ -113,6 +113,8 @@ Thanks to Jeff Gray for the mega example [float] === Notes and Warnings For USB CDC serial ports (e.g. `Serial` on the Leonardo), `Serial.begin()` is irrelevant. You can use any baud rate and configuration for serial communication with these ports. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +The only `config` value supported for `Serial1` on the Arduino Nano 33 BLE and Nano 33 BLE Sense boards is `SERIAL_8N1`. [%hardbreaks] -- From 5c6f13a89c73eaaa347da805660d62039a5921be Mon Sep 17 00:00:00 2001 From: Ubi de Feo Date: Wed, 21 Oct 2020 08:14:53 +0200 Subject: [PATCH 031/184] Include Nano 33 and Portenta (#791) * Include Nano 33 and Portenta These boards are lacking in this piece of documentation, possibly elsewhere * Update Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc Co-authored-by: per1234 * Update Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc Yes! I just discovered that such method is not available and throws an error. I believe it should be added to cores which do not support multiple resolutions, just in case a user obtains a sketch made on an *arm* board and the compilation error makes no sense to them. The method could be just a sinkhole but would prevent the compile error :) Co-authored-by: per1234 * changed subcategory to "Analog I/O" * Sub-category changed back to "Zero, Due & MKR Family" In order to submit a new PR with just the category change Co-authored-by: per1234 --- .../Zero, Due, MKR Family/analogReadResolution.adoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc b/Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc index 8dbf51d92..4531306b3 100644 --- a/Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc +++ b/Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc @@ -16,11 +16,12 @@ subCategories: [ "Zero, Due & MKR Family" ] [float] === Description -analogReadResolution() is an extension of the Analog API for the Arduino Due, Zero and MKR Family. +analogReadResolution() is an extension of the Analog API for the Zero, Due, MKR family, Nano 33 (BLE and IoT) and Portenta. Sets the size (in bits) of the value returned by `analogRead()`. It defaults to 10 bits (returns values between 0-1023) for backward compatibility with AVR based boards. -The *Due, Zero and MKR Family* boards have 12-bit ADC capabilities that can be accessed by changing the resolution to 12. This will return values from `analogRead()` between 0 and 4095. +The *Zero, Due, MKR family and Nano 33 (BLE and IoT)* boards have 12-bit ADC capabilities that can be accessed by changing the resolution to 12. This will return values from `analogRead()` between 0 and 4095. + +The *Portenta H7* has a 16 bit ADC, which will allow values between 0 and 65535. [%hardbreaks] @@ -31,7 +32,7 @@ The *Due, Zero and MKR Family* boards have 12-bit ADC capabilities that can be a [float] === Parameters -`bits`: determines the resolution (in bits) of the value returned by the `analogRead()` function. You can set this between 1 and 32. You can set resolutions higher than 12 but values returned by `analogRead()` will suffer approximation. See the note below for details. +`bits`: determines the resolution (in bits) of the value returned by the `analogRead()` function. You can set this between 1 and 32. You can set resolutions higher than the supported 12 or 16 bits, but values returned by `analogRead()` will suffer approximation. See the note below for details. [float] From 5fc2f4a85a01dea2577d9c517313fce1af902d5a Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Mon, 26 Oct 2020 14:40:07 +0100 Subject: [PATCH 032/184] Update tone.adoc Updated broken links --- Language/Functions/Advanced IO/tone.adoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Language/Functions/Advanced IO/tone.adoc b/Language/Functions/Advanced IO/tone.adoc index 41e3f5031..7f4aa3561 100644 --- a/Language/Functions/Advanced IO/tone.adoc +++ b/Language/Functions/Advanced IO/tone.adoc @@ -75,11 +75,11 @@ If you want to play different pitches on multiple pins, you need to call `noTone [role="example"] -* #EXAMPLE# http://arduino.cc/en/Tutorial/Tone[Tone Melody^] -* #EXAMPLE# http://arduino.cc/en/Tutorial/tonePitchFollower[Pitch Follower^] -* #EXAMPLE# http://arduino.cc/en/Tutorial/Tone3[Tone Keyboard^] -* #EXAMPLE# http://arduino.cc/en/Tutorial/Tone4[Tone Multiple^] -* #EXAMPLE# http://arduino.cc/en/Tutorial/PWM[PWM^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMelody[Tone Melody^] +* #EXAMPLE# https://arduino.cc/en/Tutorial/tonePitchFollower[Pitch Follower^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneKeyboard[Tone Keyboard^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMultiple[Tone Multiple^] +* #EXAMPLE# https://arduino.cc/en/Tutorial/PWM[PWM^] -- // SEE ALSO SECTION ENDS From 6b2e27d64e8b051cd68b5e50a9cce8bad5044382 Mon Sep 17 00:00:00 2001 From: HansM Date: Mon, 2 Nov 2020 20:20:24 +0100 Subject: [PATCH 033/184] Unified links in tone.adoc. --- Language/Functions/Advanced IO/tone.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Advanced IO/tone.adoc b/Language/Functions/Advanced IO/tone.adoc index 7f4aa3561..04b4debad 100644 --- a/Language/Functions/Advanced IO/tone.adoc +++ b/Language/Functions/Advanced IO/tone.adoc @@ -76,10 +76,10 @@ If you want to play different pitches on multiple pins, you need to call `noTone [role="example"] * #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMelody[Tone Melody^] -* #EXAMPLE# https://arduino.cc/en/Tutorial/tonePitchFollower[Pitch Follower^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/tonePitchFollower[Pitch Follower^] * #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneKeyboard[Tone Keyboard^] * #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMultiple[Tone Multiple^] -* #EXAMPLE# https://arduino.cc/en/Tutorial/PWM[PWM^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/PWM[PWM^] -- // SEE ALSO SECTION ENDS From e0c99a3d14cc63f651b2d8a844a1d5cb6ae03c7a Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Mon, 16 Nov 2020 12:16:09 +0100 Subject: [PATCH 034/184] Update tone.adoc added www to links --- Language/Functions/Advanced IO/tone.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Advanced IO/tone.adoc b/Language/Functions/Advanced IO/tone.adoc index 7f4aa3561..04b4debad 100644 --- a/Language/Functions/Advanced IO/tone.adoc +++ b/Language/Functions/Advanced IO/tone.adoc @@ -76,10 +76,10 @@ If you want to play different pitches on multiple pins, you need to call `noTone [role="example"] * #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMelody[Tone Melody^] -* #EXAMPLE# https://arduino.cc/en/Tutorial/tonePitchFollower[Pitch Follower^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/tonePitchFollower[Pitch Follower^] * #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneKeyboard[Tone Keyboard^] * #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneMultiple[Tone Multiple^] -* #EXAMPLE# https://arduino.cc/en/Tutorial/PWM[PWM^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/PWM[PWM^] -- // SEE ALSO SECTION ENDS From f4dceaa48b8b57e5df403711ca0427ca14c5c1e1 Mon Sep 17 00:00:00 2001 From: kb7hunter <61283239+kb7hunter@users.noreply.github.com> Date: Mon, 30 Nov 2020 14:53:28 -0700 Subject: [PATCH 035/184] Update if.adoc (#798) The if condition (if true) will execute the FOLLOWING statement, not the preceding statement. --- Language/Structure/Control Structure/if.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Structure/Control Structure/if.adoc b/Language/Structure/Control Structure/if.adoc index f1a79934e..f5c300396 100644 --- a/Language/Structure/Control Structure/if.adoc +++ b/Language/Structure/Control Structure/if.adoc @@ -16,7 +16,7 @@ subCategories: [ "Control Structure" ] -- [float] === Description -The `if` statement checks for a condition and executes the proceeding statement or set of statements if the condition is 'true'. +The `if` statement checks for a condition and executes the following statement or set of statements if the condition is 'true'. [%hardbreaks] [float] From a71ac0215829638ee960864784f6925b45f7b8ef Mon Sep 17 00:00:00 2001 From: adrianTNT Date: Mon, 30 Nov 2020 23:54:54 +0200 Subject: [PATCH 036/184] Update millis.adoc (#797) * Update millis.adoc changed variable named "time" to "my_time", because it was a conflict when compiling on ESP32 board; And it is not a good practice to define such generic variables that could be used in system variables. Using user variables like my_time and my_temp_sensor is much easier to understand for beginners and more intuitive, easier to differentiate from the system variables. * Update millis.adoc --- Language/Functions/Time/millis.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Language/Functions/Time/millis.adoc b/Language/Functions/Time/millis.adoc index d031efded..ea3b9ab4e 100644 --- a/Language/Functions/Time/millis.adoc +++ b/Language/Functions/Time/millis.adoc @@ -47,16 +47,16 @@ This example code prints on the serial port the number of milliseconds passed si [source,arduino] ---- -unsigned long time; +unsigned long myTime; void setup() { Serial.begin(9600); } void loop() { Serial.print("Time: "); - time = millis(); + myTime = millis(); - Serial.println(time); //prints time since program started + Serial.println(myTime); //prints time since program started delay(1000); // wait a second so as not to send massive amounts of data } ---- From 8b8d129bbd35a5e3142b7acde2477258d64d9f73 Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Tue, 15 Dec 2020 13:50:26 +0100 Subject: [PATCH 037/184] Update while.adoc Fixed While loop link --- Language/Structure/Control Structure/while.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Structure/Control Structure/while.adoc b/Language/Structure/Control Structure/while.adoc index 491cceb88..09b25192c 100644 --- a/Language/Structure/Control Structure/while.adoc +++ b/Language/Structure/Control Structure/while.adoc @@ -71,7 +71,7 @@ while (var < 200) { [role="language"] [role="example"] -* #EXAMPLE# https://arduino.cc/en/Tutorial/WhileLoop[While Loop^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/WhileStatementConditional[While Loop^] -- // SEE ALSO SECTION ENDS From 4d562dba41e9dd6e46fd7b7309549b32960de166 Mon Sep 17 00:00:00 2001 From: cousteau Date: Fri, 25 Dec 2020 17:49:46 +0000 Subject: [PATCH 038/184] Replace "B..." binary constants with "0b..." (#793) Replaced all references to the deprecated "B..." binary format (e.g. B00101010) with the GCC- and C++-compliant "0b..." format (e.g. 0b00101010). This also removes the restriction that binary constants must be 8 bits or less, so I'm removing that part as well. --- .../Structure/Bitwise Operators/bitwiseAnd.adoc | 2 +- .../Structure/Bitwise Operators/bitwiseOr.adoc | 2 +- .../Structure/Bitwise Operators/bitwiseXor.adoc | 4 ++-- .../Compound Operators/compoundBitwiseAnd.adoc | 12 ++++++------ .../Compound Operators/compoundBitwiseOr.adoc | 12 ++++++------ .../Compound Operators/compoundBitwiseXor.adoc | 12 ++++++------ Language/Variables/Constants/integerConstants.adoc | 14 ++++---------- 7 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Language/Structure/Bitwise Operators/bitwiseAnd.adoc b/Language/Structure/Bitwise Operators/bitwiseAnd.adoc index 986a37fcc..eb8a2067b 100644 --- a/Language/Structure/Bitwise Operators/bitwiseAnd.adoc +++ b/Language/Structure/Bitwise Operators/bitwiseAnd.adoc @@ -58,7 +58,7 @@ One of the most common uses of bitwise AND is to select a particular bit (or bit [source,arduino] ---- -PORTD = PORTD & B00000011; // clear out bits 2 - 7, leave pins PD0 and PD1 untouched (xx & 11 == xx) +PORTD = PORTD & 0b00000011; // clear out bits 2 - 7, leave pins PD0 and PD1 untouched (xx & 11 == xx) ---- -- diff --git a/Language/Structure/Bitwise Operators/bitwiseOr.adoc b/Language/Structure/Bitwise Operators/bitwiseOr.adoc index 14d894b8a..c0297fea7 100644 --- a/Language/Structure/Bitwise Operators/bitwiseOr.adoc +++ b/Language/Structure/Bitwise Operators/bitwiseOr.adoc @@ -56,7 +56,7 @@ One of the most common uses of the Bitwise OR is to set multiple bits in a bit-p // Note: This code is AVR architecture specific // set direction bits for pins 2 to 7, leave PD0 and PD1 untouched (xx | 00 == xx) // same as pinMode(pin, OUTPUT) for pins 2 to 7 on Uno or Nano -DDRD = DDRD | B11111100; +DDRD = DDRD | 0b11111100; ---- -- diff --git a/Language/Structure/Bitwise Operators/bitwiseXor.adoc b/Language/Structure/Bitwise Operators/bitwiseXor.adoc index d4677dbf9..995040657 100644 --- a/Language/Structure/Bitwise Operators/bitwiseXor.adoc +++ b/Language/Structure/Bitwise Operators/bitwiseXor.adoc @@ -56,12 +56,12 @@ The ^ operator is often used to toggle (i.e. change from 0 to 1, or 1 to 0) some // Note: This code uses registers specific to AVR microcontrollers (Uno, Nano, Leonardo, Mega, etc.) // it will not compile for other architectures void setup() { - DDRB = DDRB | B00100000; // set PB5 (pin 13 on Uno/Nano, pin 9 on Leonardo/Micro, pin 11 on Mega) as OUTPUT + DDRB = DDRB | 0b00100000; // set PB5 (pin 13 on Uno/Nano, pin 9 on Leonardo/Micro, pin 11 on Mega) as OUTPUT Serial.begin(9600); } void loop() { - PORTB = PORTB ^ B00100000; // invert PB5, leave others untouched + PORTB = PORTB ^ 0b00100000; // invert PB5, leave others untouched delay(100); } ---- diff --git a/Language/Structure/Compound Operators/compoundBitwiseAnd.adoc b/Language/Structure/Compound Operators/compoundBitwiseAnd.adoc index 2e33d7317..aa31bb88a 100644 --- a/Language/Structure/Compound Operators/compoundBitwiseAnd.adoc +++ b/Language/Structure/Compound Operators/compoundBitwiseAnd.adoc @@ -54,22 +54,22 @@ Bits that are "bitwise ANDed" with 0 are cleared to 0 so, if myByte is a byte va [source,arduino] ---- -myByte & B00000000 = 0; +myByte & 0b00000000 = 0; ---- Bits that are "bitwise ANDed" with 1 are unchanged so, [source,arduino] ---- -myByte & B11111111 = myByte; +myByte & 0b11111111 = myByte; ---- [%hardbreaks] [float] === Notes and Warnings -Because we are dealing with bits in a bitwise operator - it is convenient to use the binary formatter with constants. The numbers are still the same value in other representations, they are just not as easy to understand. Also, B00000000 is shown for clarity, but zero in any number format is zero (hmmm something philosophical there?) +Because we are dealing with bits in a bitwise operator - it is convenient to use the binary formatter with constants. The numbers are still the same value in other representations, they are just not as easy to understand. Also, 0b00000000 is shown for clarity, but zero in any number format is zero (hmmm something philosophical there?) -Consequently - to clear (set to zero) bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise AND operator (&=) with the constant B11111100 +Consequently - to clear (set to zero) bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise AND operator (&=) with the constant 0b11111100 1 0 1 0 1 0 1 0 variable 1 1 1 1 1 1 0 0 mask @@ -93,8 +93,8 @@ So if: [source,arduino] ---- -myByte = B10101010; -myByte &= B11111100; // results in B10101000 +myByte = 0b10101010; +myByte &= 0b11111100; // results in 0b10101000 ---- [%hardbreaks] diff --git a/Language/Structure/Compound Operators/compoundBitwiseOr.adoc b/Language/Structure/Compound Operators/compoundBitwiseOr.adoc index 815d98771..5cae450f2 100644 --- a/Language/Structure/Compound Operators/compoundBitwiseOr.adoc +++ b/Language/Structure/Compound Operators/compoundBitwiseOr.adoc @@ -49,22 +49,22 @@ A review of the Bitwise OR `|` operator: Bits that are "bitwise ORed" with 0 are unchanged, so if myByte is a byte variable, [source,arduino] ---- -myByte | B00000000 = myByte; +myByte | 0b00000000 = myByte; ---- Bits that are "bitwise ORed" with 1 are set to 1 so: [source,arduino] ---- -myByte | B11111111 = B11111111; +myByte | 0b11111111 = 0b11111111; ---- [%hardbreaks] [float] === Notes and Warnings -Because we are dealing with bits in a bitwise operator - it is convenient to use the binary formatter with constants. The numbers are still the same value in other representations, they are just not as easy to understand. Also, B00000000 is shown for clarity, but zero in any number format is zero. +Because we are dealing with bits in a bitwise operator - it is convenient to use the binary formatter with constants. The numbers are still the same value in other representations, they are just not as easy to understand. Also, 0b00000000 is shown for clarity, but zero in any number format is zero. [%hardbreaks] -Consequently - to set bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise OR operator (|=) with the constant B00000011 +Consequently - to set bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise OR operator (|=) with the constant 0b00000011 1 0 1 0 1 0 1 0 variable 0 0 0 0 0 0 1 1 mask @@ -88,8 +88,8 @@ Here is the same representation with the variables bits replaced with the symbol So if: [source,arduino] ---- -myByte = B10101010; -myByte |= B00000011 == B10101011; +myByte = 0b10101010; +myByte |= 0b00000011 == 0b10101011; ---- -- diff --git a/Language/Structure/Compound Operators/compoundBitwiseXor.adoc b/Language/Structure/Compound Operators/compoundBitwiseXor.adoc index 267d44fd9..8ddecc915 100644 --- a/Language/Structure/Compound Operators/compoundBitwiseXor.adoc +++ b/Language/Structure/Compound Operators/compoundBitwiseXor.adoc @@ -49,22 +49,22 @@ A review of the Bitwise XOR `^` operator: Bits that are "bitwise XORed" with 0 are left unchanged. So if myByte is a byte variable, [source,arduino] ---- -myByte ^ B00000000 = myByte; +myByte ^ 0b00000000 = myByte; ---- Bits that are "bitwise XORed" with 1 are toggled so: [source,arduino] ---- -myByte ^ B11111111 = ~myByte; +myByte ^ 0b11111111 = ~myByte; ---- [%hardbreaks] [float] === Notes and Warnings -Because we are dealing with bits in a bitwise operator - it is convenient to use the binary formatter with constants. The numbers are still the same value in other representations, they are just not as easy to understand. Also, B00000000 is shown for clarity, but zero in any number format is zero. +Because we are dealing with bits in a bitwise operator - it is convenient to use the binary formatter with constants. The numbers are still the same value in other representations, they are just not as easy to understand. Also, 0b00000000 is shown for clarity, but zero in any number format is zero. [%hardbreaks] -Consequently - to toggle bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise XOR operator (^=) with the constant B00000011 +Consequently - to toggle bits 0 & 1 of a variable, while leaving the rest of the variable unchanged, use the compound bitwise XOR operator (^=) with the constant 0b00000011 1 0 1 0 1 0 1 0 variable 0 0 0 0 0 0 1 1 mask @@ -88,8 +88,8 @@ Here is the same representation with the variables bits replaced with the symbol So if: [source,arduino] ---- -myByte = B10101010; -myByte ^= B00000011 == B10101001; +myByte = 0b10101010; +myByte ^= 0b00000011 == 0b10101001; ---- -- diff --git a/Language/Variables/Constants/integerConstants.adoc b/Language/Variables/Constants/integerConstants.adoc index d34e50370..71e93ed15 100644 --- a/Language/Variables/Constants/integerConstants.adoc +++ b/Language/Variables/Constants/integerConstants.adoc @@ -32,9 +32,9 @@ Normally, integer constants are treated as base 10 (decimal) integers, but speci | |2 (binary) -|B1111011 -|leading 'B' -|only works with 8 bit values (0 to 255) characters 0&1 valid +|0b1111011 +|leading "0b" +|characters 0&1 valid |8 (octal) |0173 @@ -76,13 +76,7 @@ Only the characters 0 and 1 are valid. === Example Code: [source,arduino] ---- -n = B101; // same as 5 decimal ((1 * 2^2) + (0 * 2^1) + 1) ----- - -The binary formatter only works on bytes (8 bits) between 0 (B0) and 255 (B11111111). If it is convenient to input an int (16 bits) in binary form you can do it a two-step procedure such as: -[source,arduino] ----- -myInt = (B11001100 * 256) + B10101010; // B11001100 is the high byte` +n = 0b101; // same as 5 decimal ((1 * 2^2) + (0 * 2^1) + 1) ---- [%hardbreaks] From 62ee09c29710b26b6c9b853cbe44d56781394531 Mon Sep 17 00:00:00 2001 From: jguy584 <77988812+jguy584@users.noreply.github.com> Date: Mon, 25 Jan 2021 13:53:41 -0500 Subject: [PATCH 039/184] Update attachInterrupt.adoc for MEGA Using pins 20, 21 for interrupts on the MEGA 2560 can cause some real headaches if not aware that they have external pull up resistors on them. The pull ups are there for TWI functionality, and cannot be disabled shy of desoldering the resistors from the board. I can confirm that the 2560 and the ADK both have these resistors. I do not know about the original MEGA, but I assume it has them too. --- Language/Functions/External Interrupts/attachInterrupt.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index 0a618e52c..a560620b9 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -22,7 +22,7 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you |Board |Digital Pins Usable For Interrupts |Uno, Nano, Mini, other 328-based |2, 3 |Uno WiFi Rev.2, Nano Every |all digital pins -|Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 +|Mega, Mega2560, MegaADK |2, 3, 18, 19, 20*, 21* |Micro, Leonardo, other 32u4-based |0, 1, 2, 3, 7 |Zero |all digital pins, except 4 |MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2 @@ -32,6 +32,7 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you |101 |all digital pins (Only pins 2, 5, 7, 8, 10, 11, 12, 13 work with *CHANGE*) |=================================================== +*Pins 20 and 21 of the MEGA series have external 10Kohm pull-up resistors attached to them that cannot be disabled. [%hardbreaks] [float] From bd73a139012e1cf6cceebc985311decb231d86b3 Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Tue, 23 Feb 2021 16:07:20 +0100 Subject: [PATCH 040/184] Add info about resolution on Portenta boards (#818) --- Language/Functions/Time/micros.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Time/micros.adoc b/Language/Functions/Time/micros.adoc index 92f274ab6..22fc13962 100644 --- a/Language/Functions/Time/micros.adoc +++ b/Language/Functions/Time/micros.adoc @@ -17,7 +17,7 @@ subCategories: [ "Time" ] [float] === Description -Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 70 minutes. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds. +Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 70 minutes. On the boards from the Arduino Portenta family this function has a resolution of one microsecond on all cores. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds. [%hardbreaks] From c4fcc2497eb135d3981f0588425d201197ffdea5 Mon Sep 17 00:00:00 2001 From: George Keloglou Date: Wed, 10 Mar 2021 02:06:27 +0200 Subject: [PATCH 041/184] Space after slashes for comments. (#716) Co-authored-by: per1234 --- Language/Functions/Time/millis.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Time/millis.adoc b/Language/Functions/Time/millis.adoc index ea3b9ab4e..7ff5f7624 100644 --- a/Language/Functions/Time/millis.adoc +++ b/Language/Functions/Time/millis.adoc @@ -56,7 +56,7 @@ void loop() { Serial.print("Time: "); myTime = millis(); - Serial.println(myTime); //prints time since program started + Serial.println(myTime); // prints time since program started delay(1000); // wait a second so as not to send massive amounts of data } ---- From 97aa6957474a9e32cdcff74246a54bca31c87c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 12 Mar 2021 16:18:50 +0100 Subject: [PATCH 042/184] Updated mega row for interrupts --- Language/Functions/External Interrupts/attachInterrupt.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index 0a618e52c..0dc26d858 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -22,7 +22,7 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you |Board |Digital Pins Usable For Interrupts |Uno, Nano, Mini, other 328-based |2, 3 |Uno WiFi Rev.2, Nano Every |all digital pins -|Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 +|Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 (*pins 20 & 21* are not available to use for interrupts while they are used for I2C communication) |Micro, Leonardo, other 32u4-based |0, 1, 2, 3, 7 |Zero |all digital pins, except 4 |MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2 From fca865ba7b9ae7244be23f6364ae0986d3196bb9 Mon Sep 17 00:00:00 2001 From: Marco Tedaldi Date: Thu, 18 Mar 2021 10:36:59 +0100 Subject: [PATCH 043/184] Update serialEvent.adoc Add mention of loop() in description. --- Language/Functions/Communication/Serial/serialEvent.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Serial/serialEvent.adoc b/Language/Functions/Communication/Serial/serialEvent.adoc index e554fb882..5201017eb 100644 --- a/Language/Functions/Communication/Serial/serialEvent.adoc +++ b/Language/Functions/Communication/Serial/serialEvent.adoc @@ -14,7 +14,7 @@ title: serialEvent() [float] === Description -Called when data is available. Use `Serial.read()` to capture this data. +Called at the end of loop() when data is available. Use `Serial.read()` to capture this data. [%hardbreaks] From aa6751cf647f751da64c3eb0d4e894ca4f2258bd Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 28 Mar 2021 21:44:43 -0700 Subject: [PATCH 044/184] Use standard pin name in attachInterrupt() table (#807) The previous pin number 15 in the table for Nano 33 IoT was correct, but users are more familiar with the "An" pin naming style, as marked on the board silkscreen, so it's better to always use those names in the reference. --- Language/Functions/External Interrupts/attachInterrupt.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index 0a618e52c..5da092da2 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -26,7 +26,7 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you |Micro, Leonardo, other 32u4-based |0, 1, 2, 3, 7 |Zero |all digital pins, except 4 |MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2 -|Nano 33 IoT |2, 3, 9, 10, 11, 13, 15, A5, A7 +|Nano 33 IoT |2, 3, 9, 10, 11, 13, A1, A5, A7 |Nano 33 BLE, Nano 33 BLE Sense |all pins |Due |all digital pins |101 |all digital pins (Only pins 2, 5, 7, 8, 10, 11, 12, 13 work with *CHANGE*) From e893eb10155b388716742fe516705b42096709dd Mon Sep 17 00:00:00 2001 From: Vincent Tavernier Date: Wed, 21 Apr 2021 18:19:21 +0200 Subject: [PATCH 045/184] Specify behavior of analogWrite on Nano 33 BLE/BLE Sense --- Language/Functions/Analog IO/analogWrite.adoc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 95402cba0..672f398a0 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -25,16 +25,17 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C | Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) | Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) | Uno WiFi Rev2, Nano Every | 3, 5, 6, 9, 10 | 976 Hz -| MKR boards * | 0 - 8, 10, A3, A4 | 732 Hz -| MKR1000 WiFi * | 0 - 8, 10, 11, A3, A4 | 732 Hz -| Zero * | 3 - 13, A0, A1 | 732 Hz -| Nano 33 IoT * | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz -| Nano 33 BLE/BLE Sense | 1 - 13, A0 - A7 | 500 Hz -| Due ** | 2-13 | 1000 Hz +| MKR boards ¹ | 0 - 8, 10, A3, A4 | 732 Hz +| MKR1000 WiFi ¹ | 0 - 8, 10, 11, A3, A4 | 732 Hz +| Zero ¹ | 3 - 13, A0, A1 | 732 Hz +| Nano 33 IoT ¹ | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz +| Nano 33 BLE/BLE Sense ² | 1 - 13, A0 - A7 | 500 Hz +| Due ³ | 2-13 | 1000 Hz | 101 | 3, 5, 6, 9 | pins 3 and 9: 490 Hz, pins 5 and 6: 980 Hz |======================================================================================================== -{empty}* In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + -{empty}** In addition to PWM capabilities on the pins noted above, the Due has true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. +{empty}¹ In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + +{empty}² Only 4 different pins can be used at the same time. Enabling PWM on more than 4 pins will abort the running sketch and require resetting the board to upload a new sketch again. + +{empty}³ In addition to PWM capabilities on the pins noted above, the Due has true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. [%hardbreaks] From d958580e402e617114be796e8267cf6cffb84a21 Mon Sep 17 00:00:00 2001 From: rohoog <33842942+rohoog@users.noreply.github.com> Date: Fri, 23 Apr 2021 20:49:16 +0200 Subject: [PATCH 046/184] Update ifSerial.adoc I got bitten by this delay in a loop that otherwise would easily keep up with interrupts. I think users should be aware of it! --- Language/Functions/Communication/Serial/ifSerial.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Language/Functions/Communication/Serial/ifSerial.adoc b/Language/Functions/Communication/Serial/ifSerial.adoc index d5a0fa29f..c2988a863 100644 --- a/Language/Functions/Communication/Serial/ifSerial.adoc +++ b/Language/Functions/Communication/Serial/ifSerial.adoc @@ -36,6 +36,11 @@ None === Returns Returns true if the specified serial port is available. This will only return false if querying the Leonardo's USB CDC serial connection before it is ready. Data type: `bool`. + +[float] +=== Warning +This function adds a delay of 10ms in an attempt to solve "open but not quite" situations. Don't use it in tight loops. + -- // OVERVIEW SECTION ENDS From efc1249ce8a5c510ba5e90a77d165819b56f409f Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 25 May 2021 13:12:35 +1200 Subject: [PATCH 047/184] Change ''D" to "d" in (#831) Perhaps the code has changed over time, but this documentation change is for the reference to reflect reality. Also consider changing the code to perhaps accept HEX_UPPER & HEX_LOWER. --- Language/Variables/Data Types/stringObject.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/stringObject.adoc b/Language/Variables/Data Types/stringObject.adoc index 396582b3d..b3b04a498 100644 --- a/Language/Variables/Data Types/stringObject.adoc +++ b/Language/Variables/Data Types/stringObject.adoc @@ -36,7 +36,7 @@ gives you the String "13". You can use other bases, however. For example, String thisString = String(13, HEX); ---- -gives you the String "D", which is the hexadecimal representation of the decimal value 13. Or if you prefer binary, +gives you the String "d", which is the hexadecimal representation of the decimal value 13. Or if you prefer binary, [source,arduino] ---- From a7afd807a3e3a1ce45fef911cfaf52ed5eae1e27 Mon Sep 17 00:00:00 2001 From: rohoog <33842942+rohoog@users.noreply.github.com> Date: Sat, 29 May 2021 13:36:26 +0200 Subject: [PATCH 048/184] Update bitshiftRight.adoc Sign extension doesn't need to be avoided for arithmetic use of bit shifting, it actually causes that negative numbers are calculated correctly. Just the rounding is different compared to the division operator. --- .../Structure/Bitwise Operators/bitshiftRight.adoc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Language/Structure/Bitwise Operators/bitshiftRight.adoc b/Language/Structure/Bitwise Operators/bitshiftRight.adoc index f2f98b840..53715a33a 100644 --- a/Language/Structure/Bitwise Operators/bitshiftRight.adoc +++ b/Language/Structure/Bitwise Operators/bitshiftRight.adoc @@ -69,12 +69,19 @@ int x = -16; // binary: 1111111111110000 int y = 3; int result = (unsigned int)x >> y; // binary: 0001111111111110 ---- -If you are careful to avoid sign extension, you can use the right-shift operator `>>` as a way to divide by powers of 2. For example: +Sign extension causes that you can use the right-shift operator `>>` as a way to divide by powers of 2, even negative numbers. For example: [source,arduino] ---- -int x = 1000; -int y = x >> 3; // integer division of 1000 by 8, causing y = 125. +int x = -1000; +int y = x >> 3; // integer division of -1000 by 8, causing y = -125. +---- +But be aware of the rounding with negative numbers: +[source,arduino] +---- +int x = -1001; +int y = x >> 3; // division by shifting always rounds down, causing y = -126 +int z = x / 8; // division operator rounds towards zero, causing z = -125 ---- -- From 465ebf7d63833e471fb06d471412c98de4def7cf Mon Sep 17 00:00:00 2001 From: joshua-8 <59814881+joshua-8@users.noreply.github.com> Date: Wed, 2 Jun 2021 21:32:48 -0700 Subject: [PATCH 049/184] fixed typo (missing comma and space) (#835) --- Language/Functions/Communication/Serial/serialEvent.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Serial/serialEvent.adoc b/Language/Functions/Communication/Serial/serialEvent.adoc index e554fb882..c352bbfc6 100644 --- a/Language/Functions/Communication/Serial/serialEvent.adoc +++ b/Language/Functions/Communication/Serial/serialEvent.adoc @@ -67,7 +67,7 @@ Nothing `serialEvent()` and `serialEvent1()` don't work on the Arduino SAMD Boards -`serialEvent()`, `serialEvent1()``serialEvent2()`, and `serialEvent3()` don't work on the Arduino Due. +`serialEvent()`, `serialEvent1()`, `serialEvent2()`, and `serialEvent3()` don't work on the Arduino Due. [%hardbreaks] -- From 5e49633c1ece7987a0e1dd9009ac9e8658549271 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sat, 26 Jun 2021 08:06:16 -0700 Subject: [PATCH 050/184] Remove redundant unit from definition of HIGH level (#840) The text contained both the symbol and name of the unit consecutively. --- Language/Variables/Constants/constants.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Constants/constants.adoc b/Language/Variables/Constants/constants.adoc index ad74c9f6d..05f137654 100644 --- a/Language/Variables/Constants/constants.adoc +++ b/Language/Variables/Constants/constants.adoc @@ -41,7 +41,7 @@ When reading or writing to a digital pin there are only two possible values a pi The meaning of `HIGH` (in reference to a pin) is somewhat different depending on whether a pin is set to an `INPUT` or `OUTPUT`. When a pin is configured as an `INPUT` with `link:../../../functions/digital-io/pinmode[pinMode()]`, and read with `link:../../../functions/digital-io/digitalread[digitalRead()]`, the Arduino (ATmega) will report `HIGH` if: - a voltage greater than 3.0V is present at the pin (5V boards) - - a voltage greater than 2.0V volts is present at the pin (3.3V boards) + - a voltage greater than 2.0V is present at the pin (3.3V boards) [%hardbreaks] A pin may also be configured as an INPUT with link:../../../functions/digital-io/pinmode[`pinMode()`], and subsequently made HIGH with `link:../../../functions/digital-io/digitalwrite[digitalWrite()]`. This will enable the internal 20K pullup resistors, which will _pull up_ the input pin to a `HIGH` reading unless it is pulled `LOW` by external circuitry. This can be done alternatively by passing `INPUT_PULLUP` as argument to the link:../../../functions/digital-io/pinmode[`pinMode()`] function, as explained in more detail in the section "Defining Digital Pins modes: INPUT, INPUT_PULLUP, and OUTPUT" further below. From 99c2365cfc8c405f7f3458b477ab134677db39a9 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 7 Sep 2021 15:38:30 +1200 Subject: [PATCH 051/184] Update delayMicroseconds.adoc (#847) Improve warning about long delay times , and that they can be extremely brief. --- Language/Functions/Time/delayMicroseconds.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Time/delayMicroseconds.adoc b/Language/Functions/Time/delayMicroseconds.adoc index 0fbf57d84..2c5b02677 100644 --- a/Language/Functions/Time/delayMicroseconds.adoc +++ b/Language/Functions/Time/delayMicroseconds.adoc @@ -19,7 +19,7 @@ subCategories: [ "Time" ] === Description Pauses the program for the amount of time (in microseconds) specified by the parameter. There are a thousand microseconds in a millisecond and a million microseconds in a second. -Currently, the largest value that will produce an accurate delay is 16383. This could change in future Arduino releases. For delays longer than a few thousand microseconds, you should use `delay()` instead. +Currently, the largest value that will produce an accurate delay is 16383; larger values can produce an extremely short delay. This could change in future Arduino releases. For delays longer than a few thousand microseconds, you should use `delay()` instead. [%hardbreaks] @@ -71,7 +71,7 @@ void loop() { [float] === Notes and Warnings -This function works very accurately in the range 3 microseconds and up. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times. +This function works very accurately in the range 3 microseconds and up to 16383. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times. Larger delay times may actually delay for an extremely brief time. As of Arduino 0018, delayMicroseconds() no longer disables interrupts. From d91cefb4d256617d98ab13207db17b576af9b322 Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Sun, 12 Sep 2021 15:57:51 +0200 Subject: [PATCH 052/184] Update analogReference for Mbed OS Boards (#848) * Update analogReference for Mbed OS Boards The Mbed board platforms have been renamed and reorganized and the two previously named platforms (_Arduino mbed-enabled Boards_ and _Arduino nRF528x Boards (Mbed OS)_) no longer exist. * analogReference: Mention Mbed OS platforms separately Co-authored-by: per1234 Co-authored-by: per1234 --- Language/Functions/Analog IO/analogReference.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogReference.adoc b/Language/Functions/Analog IO/analogReference.adoc index 33cc8ad87..8b463de9d 100644 --- a/Language/Functions/Analog IO/analogReference.adoc +++ b/Language/Functions/Analog IO/analogReference.adoc @@ -52,7 +52,7 @@ Arduino SAM Boards (Due) * AR_DEFAULT: the default analog reference of 3.3V. This is the only supported option for the Due. -Arduino mbed-enabled Boards (Nano 33 BLE only): available when using the _Arduino mbed-enabled Boards_ platform, or the _Arduino nRF528x Boards (Mbed OS)_ platform version 1.1.6 or later +Arduino Mbed OS Nano Boards (Nano 33 BLE), Arduino Mbed OS Edge Boards (Edge Control) * AR_VDD: the default 3.3 V reference * AR_INTERNAL: built-in 0.6 V reference From bed5beee73ad1ae379c671c0db0e4e93a37ea699 Mon Sep 17 00:00:00 2001 From: Arnold <48472227+Arnold-n@users.noreply.github.com> Date: Tue, 21 Sep 2021 21:17:50 +0200 Subject: [PATCH 053/184] Clarification TIMx use by AVR architectures --- Language/Functions/Time/millis.adoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Time/millis.adoc b/Language/Functions/Time/millis.adoc index dbc70ff54..82cb8da73 100644 --- a/Language/Functions/Time/millis.adoc +++ b/Language/Functions/Time/millis.adoc @@ -64,7 +64,9 @@ void loop() { [float] === Notes and Warnings -Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. millis() uses timer0's overflow interrupt. +Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. + +AVR-based architectures program a timer to implement millis(), reconfiguring these timers may result in inaccurate millis() readings. ArduinoCore-AVR relies on TIM0 which is programmed to generate an interrupt every 16384 clock cycles (clock divider set to 64, overflow every 256 ticks). The same holds for ArduinoCore-mega-AVR, except that it uses TIMx if MILLIS_USER_TIMx (0<=x<=3) is defined. -- // HOW TO USE SECTION ENDS From ecd4dfc78bcd4fe12f9e54489cddae38c3ac8070 Mon Sep 17 00:00:00 2001 From: Arnold <48472227+Arnold-n@users.noreply.github.com> Date: Tue, 21 Sep 2021 21:31:38 +0200 Subject: [PATCH 054/184] Clarification Systick use by SAM(D) architectures --- Language/Functions/Time/millis.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Time/millis.adoc b/Language/Functions/Time/millis.adoc index 82cb8da73..0722bd1fb 100644 --- a/Language/Functions/Time/millis.adoc +++ b/Language/Functions/Time/millis.adoc @@ -66,7 +66,7 @@ void loop() { === Notes and Warnings Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. -AVR-based architectures program a timer to implement millis(), reconfiguring these timers may result in inaccurate millis() readings. ArduinoCore-AVR relies on TIM0 which is programmed to generate an interrupt every 16384 clock cycles (clock divider set to 64, overflow every 256 ticks). The same holds for ArduinoCore-mega-AVR, except that it uses TIMx if MILLIS_USER_TIMx (0<=x<=3) is defined. +On some architectures reconfiguration of timers may result in inaccurate millis() readings. AVR-based architectures program a timer to implement millis(): ArduinoCore-AVR programs TIM0 to generate an interrupt every 16384 clock cycles (clock divider set to 64, overflow every 256 ticks). The same holds for ArduinoCore-mega-AVR, except that it uses TIMx if MILLIS_USER_TIMx (0<=x<=3) is defined. The ArduinoCore-SAM(D) architectures rely on the Systick timer which is programmed to generate an interrupt every 1 ms. -- // HOW TO USE SECTION ENDS From 36b385799dca3dc2695bfae60ae5a0dd23a7f15b Mon Sep 17 00:00:00 2001 From: Arnold <48472227+Arnold-n@users.noreply.github.com> Date: Tue, 21 Sep 2021 21:36:29 +0200 Subject: [PATCH 055/184] Simplify language. --- Language/Functions/Time/millis.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Time/millis.adoc b/Language/Functions/Time/millis.adoc index 0722bd1fb..10514ad67 100644 --- a/Language/Functions/Time/millis.adoc +++ b/Language/Functions/Time/millis.adoc @@ -66,7 +66,7 @@ void loop() { === Notes and Warnings Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. -On some architectures reconfiguration of timers may result in inaccurate millis() readings. AVR-based architectures program a timer to implement millis(): ArduinoCore-AVR programs TIM0 to generate an interrupt every 16384 clock cycles (clock divider set to 64, overflow every 256 ticks). The same holds for ArduinoCore-mega-AVR, except that it uses TIMx if MILLIS_USER_TIMx (0<=x<=3) is defined. The ArduinoCore-SAM(D) architectures rely on the Systick timer which is programmed to generate an interrupt every 1 ms. +On some architectures reconfiguration of timers may result in inaccurate millis() readings. AVR-based architectures program a timer to implement millis(): ArduinoCore-AVR programs TIM0 to generate an interrupt every 16384 clock cycles (clock divider set to 64, overflow every 256 ticks). The same holds for ArduinoCore-mega-AVR, except that it uses TIMx if MILLIS_USER_TIMx (0<=x<=3) is defined. The ArduinoCore-SAM(D) architectures program the Systick timer to generate an interrupt every 1 ms. -- // HOW TO USE SECTION ENDS From 86383e106bfeedb199383f495a300df289c784e1 Mon Sep 17 00:00:00 2001 From: "Brian A. Danielak" Date: Wed, 20 Oct 2021 14:00:15 -0400 Subject: [PATCH 056/184] Make array size match array literal size (#851) --- Language/Variables/Data Types/array.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/array.adoc b/Language/Variables/Data Types/array.adoc index b038a83db..9e16293a0 100644 --- a/Language/Variables/Data Types/array.adoc +++ b/Language/Variables/Data Types/array.adoc @@ -21,7 +21,7 @@ All of the methods below are valid ways to create (declare) an array. ---- int myInts[6]; int myPins[] = {2, 4, 8, 3, 6}; - int mySensVals[6] = {2, 4, -8, 3, 2}; + int mySensVals[5] = {2, 4, -8, 3, 2}; char message[6] = "hello"; ---- You can declare an array without initializing it as in myInts. From ea5cdd5037233c364e9c68db186c2c53decaf1cc Mon Sep 17 00:00:00 2001 From: jbchilders <58781054+jbchilders@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:40:12 -0400 Subject: [PATCH 057/184] Update for.adoc --- Language/Structure/Control Structure/for.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Structure/Control Structure/for.adoc b/Language/Structure/Control Structure/for.adoc index 7e02a21f7..6724e1e58 100644 --- a/Language/Structure/Control Structure/for.adoc +++ b/Language/Structure/Control Structure/for.adoc @@ -51,7 +51,7 @@ for (initialization; condition; increment) { === Example Code [source,arduino] ---- -// Dim an LED using a PWM pin +// Brighten an LED using a PWM pin int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10 void setup() { From afdbba31ec269fd89b7e2b8244a1e1320c864bce Mon Sep 17 00:00:00 2001 From: Melissa <54317642+mkaivo@users.noreply.github.com> Date: Tue, 2 Nov 2021 09:11:27 +0100 Subject: [PATCH 058/184] Add an example code to abs() [CNT-1196] (#841) * Add an example code to abs() CNT-1196 Hi, we got a request to add an example code of abs(). Could this work? It is a pretty straightforward function. See the Jira task here: https://arduino.atlassian.net/browse/CNT-1196 * Update abs.adoc * Update Language/Functions/Math/abs.adoc Co-authored-by: per1234 Co-authored-by: per1234 --- Language/Functions/Math/abs.adoc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Language/Functions/Math/abs.adoc b/Language/Functions/Math/abs.adoc index c24610f7a..d494e4c1f 100644 --- a/Language/Functions/Math/abs.adoc +++ b/Language/Functions/Math/abs.adoc @@ -45,7 +45,34 @@ Calculates the absolute value of a number. // HOW TO USE SECTION STARTS [#howtouse] -- +[float] +=== Example Code +// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄ +Prints the absolute value of variable `x` to the Serial Monitor. +[source,arduino] +---- +void setup() { + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + int x = 42; + Serial.print("The absolute value of "); + Serial.print(x); + Serial.print(" is "); + Serial.println(abs(x)); + x = -42; + Serial.print("The absolute value of "); + Serial.print(x); + Serial.print(" is "); + Serial.println(abs(x)); +} + +void loop() { +} +---- +[%hardbreaks] [float] === Notes and Warnings From 251e4d21ad9932d9dc703a4206c7f2662f279dc0 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Fri, 5 Nov 2021 23:39:57 +0100 Subject: [PATCH 059/184] Add missing space in ASCII DOC line break --- Language/Functions/USB/Keyboard/keyboardPrintln.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/USB/Keyboard/keyboardPrintln.adoc b/Language/Functions/USB/Keyboard/keyboardPrintln.adoc index 1ae3551ce..3a6b8b5cc 100644 --- a/Language/Functions/USB/Keyboard/keyboardPrintln.adoc +++ b/Language/Functions/USB/Keyboard/keyboardPrintln.adoc @@ -23,7 +23,7 @@ Sends a keystroke to a connected computer, followed by a newline and carriage re [float] === Syntax `Keyboard.println()` + -`Keyboard.println(character)`+ +`Keyboard.println(character)` + `Keyboard.println(characters)` From dc145796273217bb435519965461c46c20889b22 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Fri, 5 Nov 2021 23:54:51 +0100 Subject: [PATCH 060/184] Copy edit keyboardPrint{,ln}.adoc - a string is sent as multiple keystrokes, not as a single keystroke - these functions return the number of keystrokes sent, which is far smaller than the number of bytes. --- Language/Functions/USB/Keyboard/keyboardPrint.adoc | 6 +++--- Language/Functions/USB/Keyboard/keyboardPrintln.adoc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardPrint.adoc b/Language/Functions/USB/Keyboard/keyboardPrint.adoc index 1f5014d73..f93530145 100644 --- a/Language/Functions/USB/Keyboard/keyboardPrint.adoc +++ b/Language/Functions/USB/Keyboard/keyboardPrint.adoc @@ -14,7 +14,7 @@ title: Keyboard.print() [float] === Description -Sends a keystroke to a connected computer. +Sends one or more keystrokes to a connected computer. `Keyboard.print()` must be called after initiating link:../keyboardbegin[Keyboard.begin()]. [%hardbreaks] @@ -29,12 +29,12 @@ Sends a keystroke to a connected computer. [float] === Parameters `character`: a char or int to be sent to the computer as a keystroke. + -`characters`: a string to be sent to the computer as a keystroke. +`characters`: a string to be sent to the computer as keystrokes. [float] === Returns -Number of bytes sent. Data type: `size_t`. +Number of keystrokes sent. Data type: `size_t`. -- // OVERVIEW SECTION ENDS diff --git a/Language/Functions/USB/Keyboard/keyboardPrintln.adoc b/Language/Functions/USB/Keyboard/keyboardPrintln.adoc index 3a6b8b5cc..43deaf2fa 100644 --- a/Language/Functions/USB/Keyboard/keyboardPrintln.adoc +++ b/Language/Functions/USB/Keyboard/keyboardPrintln.adoc @@ -14,7 +14,7 @@ title: Keyboard.println() [float] === Description -Sends a keystroke to a connected computer, followed by a newline and carriage return. +Sends one or more keystrokes to a connected computer, followed by a newline and carriage return. `Keyboard.println()` must be called after initiating link:../keyboardbegin[Keyboard.begin()]. [%hardbreaks] @@ -30,12 +30,12 @@ Sends a keystroke to a connected computer, followed by a newline and carriage re [float] === Parameters `character`: a char or int to be sent to the computer as a keystroke, followed by newline and carriage return. + -`characters`: a string to be sent to the computer as a keystroke, followed by a newline and carriage return. +`characters`: a string to be sent to the computer as keystrokes, followed by a newline and carriage return. [float] === Returns -Number of bytes sent. Data type: `size_t`. +Number of keystrokes sent. Data type: `size_t`. -- // OVERVIEW SECTION ENDS From 8c498c1836c99b95707bab3ae77cf0c7dc58f7bb Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sat, 6 Nov 2021 00:01:15 +0100 Subject: [PATCH 061/184] Clarify the end of lines sent by Keyboard.println There is no such thing as the "newline" or "carriage return" keys. Instead, Keyboard.println() hits the Return key, more commonly known as the Enter key. --- Language/Functions/USB/Keyboard/keyboardPrintln.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardPrintln.adoc b/Language/Functions/USB/Keyboard/keyboardPrintln.adoc index 43deaf2fa..062b9c92f 100644 --- a/Language/Functions/USB/Keyboard/keyboardPrintln.adoc +++ b/Language/Functions/USB/Keyboard/keyboardPrintln.adoc @@ -14,7 +14,7 @@ title: Keyboard.println() [float] === Description -Sends one or more keystrokes to a connected computer, followed by a newline and carriage return. +Sends one or more keystrokes to a connected computer, followed by a keystroke on the Enter key. `Keyboard.println()` must be called after initiating link:../keyboardbegin[Keyboard.begin()]. [%hardbreaks] @@ -29,8 +29,8 @@ Sends one or more keystrokes to a connected computer, followed by a newline and [float] === Parameters -`character`: a char or int to be sent to the computer as a keystroke, followed by newline and carriage return. + -`characters`: a string to be sent to the computer as keystrokes, followed by a newline and carriage return. +`character`: a char or int to be sent to the computer as a keystroke, followed by Enter. + +`characters`: a string to be sent to the computer as keystrokes, followed by Enter. [float] From 948c6c568a92dcc39d28160412a7d03c90eb5e61 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sat, 6 Nov 2021 14:31:17 +0100 Subject: [PATCH 062/184] Document the layout parameter to Keyboard.begin() --- .../Functions/USB/Keyboard/keyboardBegin.adoc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardBegin.adoc b/Language/Functions/USB/Keyboard/keyboardBegin.adoc index 1a36f3f90..f2b01694b 100644 --- a/Language/Functions/USB/Keyboard/keyboardBegin.adoc +++ b/Language/Functions/USB/Keyboard/keyboardBegin.adoc @@ -20,12 +20,26 @@ When used with a Leonardo or Due board, `Keyboard.begin()` starts emulating a ke [float] === Syntax -`Keyboard.begin()` +`Keyboard.begin()` + +`Keyboard.begin(layout)` [float] === Parameters -None +`layout`: the keyboard layout to use. This parameter is optional and defaults to `KeyboardLayout_en_US`. + + +[float] +=== Keyboard layouts +Currently, the library supports the following national keyboard layouts: + +* `KeyboardLayout_de_DE`: Germany +* `KeyboardLayout_en_US`: USA +* `KeyboardLayout_es_ES`: Spain +* `KeyboardLayout_fr_FR`: France +* `KeyboardLayout_it_IT`: Italy + +Custom layouts can be created by copying and modifying an existing layout. See the instructions in the file KeyboardLayout.h. [float] From 3a87ec432461b36d5d807fb4fd1e14ab77efdac7 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sun, 21 Nov 2021 15:28:46 +0100 Subject: [PATCH 063/184] keyboardBegin.adoc: Add Notes and Warnings Move the note on custom layouts to this new section, and be more specific on the location of the KeyboardLayout.h file. As per per1234's suggestions. --- Language/Functions/USB/Keyboard/keyboardBegin.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardBegin.adoc b/Language/Functions/USB/Keyboard/keyboardBegin.adoc index f2b01694b..2c27dbf0f 100644 --- a/Language/Functions/USB/Keyboard/keyboardBegin.adoc +++ b/Language/Functions/USB/Keyboard/keyboardBegin.adoc @@ -39,8 +39,6 @@ Currently, the library supports the following national keyboard layouts: * `KeyboardLayout_fr_FR`: France * `KeyboardLayout_it_IT`: Italy -Custom layouts can be created by copying and modifying an existing layout. See the instructions in the file KeyboardLayout.h. - [float] === Returns @@ -82,5 +80,10 @@ void loop() { } ---- + +[float] +=== Notes and Warnings +Custom layouts can be created by copying and modifying an existing layout. See the instructions in the Keyboard library's KeyboardLayout.h file. + -- // HOW TO USE SECTION ENDS From 83ea3575881ee7b7d57fd9f4fda4671cc2bb4391 Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Thu, 2 Dec 2021 15:29:24 +0100 Subject: [PATCH 064/184] Added picture for SPI documentation --- Language/Functions/Communication/SPI/api.adoc | 269 ++++++++++++++++++ .../Communication/SPI/assets/ICSPHeader.jpg | Bin 0 -> 15824 bytes 2 files changed, 269 insertions(+) create mode 100644 Language/Functions/Communication/SPI/api.adoc create mode 100644 Language/Functions/Communication/SPI/assets/ICSPHeader.jpg diff --git a/Language/Functions/Communication/SPI/api.adoc b/Language/Functions/Communication/SPI/api.adoc new file mode 100644 index 000000000..d9e8d455e --- /dev/null +++ b/Language/Functions/Communication/SPI/api.adoc @@ -0,0 +1,269 @@ +--- +title: SPISettings +categories: [ "Functions" ] +subCategories: [ "Communication" ] +--- + +== SPISettings + +[float] +==== Description + +The SPISettings object is used to configure the SPI port for your SPI device. All 3 parameters are combined to a single SPISettings object, which is given to SPI.beginTransaction(). + +When all of your settings are constants, SPISettings should be used directly in SPI.beginTransaction(). See the syntax section below. For constants, this syntax results in smaller and faster code. + +If any of your settings are variables, you may create a SPISettings object to hold the 3 settings. Then you can give the object name to SPI.beginTransaction(). Creating a named SPISettings object may be more efficient when your settings are not constants, especially if the maximum speed is a variable computed or configured, rather than a number you type directly into your sketch. + +==== Syntax + +---- +SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0)) +---- + +NOTE: Best if all 3 settings are constants + +---- +SPISettings mySettting(speedMaximum, dataOrder, dataMode) +---- + +NOTE: Best when any setting is a variable + +==== Parameters + +speedMaximum: The maximum speed of communication. For a SPI chip rated up to 20 MHz, use 20000000. + +dataOrder: MSBFIRST or LSBFIRST + +dataMode : SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3 + +==== Returns + +None. + +[float] +=== `begin()` + +==== Description + +Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. + +==== Syntax + +---- +SPI.begin() +---- + +==== Parameters + +None + +==== Returns + +None + +[float] +=== `end()` + +==== Description + +Disables the SPI bus (leaving pin modes unchanged). + +==== Syntax + +---- +SPI.end() +---- + +==== Parameters + +None + +==== Returns + +None + +[float] +=== `beginTransaction()` + +==== Description + +Initializes the SPI bus using the defined SPISettings. + +==== Syntax + +---- +SPI.beginTransaction(mySettings); +---- + +==== Parameters + +mySettings: the chosen settings according to SPISettings. + +==== Returns + +None. + +[float] +=== `endTransaction()` + +==== Description + +Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus. + +==== Syntax + +---- +SPI.endTransaction() +---- + +==== Parameters + +None. + +==== Returns + +None. + +[float] +=== `setBitOrder()` + +==== Description + +This function should not be used in new projects. Use SPISettings with SPI.beginTransaction() to configure SPI parameters. + +Sets the order of the bits shifted out of and into the SPI bus, either LSBFIRST (least-significant bit first) or MSBFIRST (most-significant bit first). + +==== Syntax + +---- +SPI.setBitOrder(order) +---- + +==== Parameters + +order: either LSBFIRST or MSBFIRST + +==== Returns + +None + +[float] +=== `setClockDivider()` + +==== Description + +This function should not be used in new projects. Use SPISettings with SPI.beginTransaction() to configure SPI parameters. + +Sets the SPI clock divider relative to the system clock. On AVR based boards, the dividers available are 2, 4, 8, 16, 32, 64 or 128. The default setting is SPI_CLOCK_DIV4, which sets the SPI clock to one-quarter the frequency of the system clock (4 Mhz for the boards at 16 MHz). + +===== Arduino Due +On the Due, the system clock can be divided by values from 1 to 255. The default value is 21, which sets the clock to 4 MHz like other Arduino boards. + +==== Syntax + +---- +SPI.setClockDivider(divider) +---- + +==== Parameters + +divider (On AVR boards): + +* SPI_CLOCK_DIV2 +* SPI_CLOCK_DIV4 +* SPI_CLOCK_DIV8 +* SPI_CLOCK_DIV16 +* SPI_CLOCK_DIV32 +* SPI_CLOCK_DIV64 +* SPI_CLOCK_DIV128 + +slaveSelectPin: + +* slave device SS pin (Arduino Due only) + +divider (Arduino Due only): + +* a number from 1 to 255 (Arduino Due only) + +==== Returns + +None + +[float] +=== `setDataMode()` + +==== Description + +This function should not be used in new projects. Use SPISettings with SPI.beginTransaction() to configure SPI parameters. + +Sets the SPI data mode: that is, clock polarity and phase. See the Wikipedia article on SPI for details. + +==== Syntax + +---- +SPI.setDataMode(mode) +---- + +==== Parameters + +mode: + +* SPI_MODE0 +* SPI_MODE1 +* SPI_MODE2 +* SPI_MODE3 + +slaveSelectPin + +* slave device SS pin (Arduino Due only) + +==== Returns + +None + +[float] +=== `transfer()` + +==== Description + +SPI transfer is based on a simultaneous send and receive: the received data is returned in receivedVal (or receivedVal16). In case of buffer transfers the received data is stored in the buffer in-place (the old data is replaced with the data received). + +==== Syntax + +---- +receivedVal = SPI.transfer(val) +receivedVal16 = SPI.transfer16(val16) +SPI.transfer(buffer, size) +---- + +==== Parameters + +* val: the byte to send out over the bus +* val16: the two bytes variable to send out over the bus +* buffer: the array of data to be transferred + +==== Returns + +the received data + +[float] +=== `usingInterrupt()` + +==== Description + +If your program will perform SPI transactions within an interrupt, call this function to register the interrupt number or name with the SPI library. This allows SPI.beginTransaction() to prevent usage conflicts. Note that the interrupt specified in the call to usingInterrupt() will be disabled on a call to beginTransaction() and re-enabled in endTransaction(). + +==== Syntax + +---- +SPI.usingInterrupt(interruptNumber) +---- + +==== Parameters + +interruptNumber: the associated interrupt number. + +==== Returns + +None. diff --git a/Language/Functions/Communication/SPI/assets/ICSPHeader.jpg b/Language/Functions/Communication/SPI/assets/ICSPHeader.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e2c463ed4918425984f94591e46aed8cbcb10a73 GIT binary patch literal 15824 zcmbt*RZv{Pm-paK@ZjzibZ~bK?#@7P3rui=ySoKqybP+PypGF2k^cQkoeE+|J42i@_z#O&*AqT045^9 z2=E94MG1h$go43@dLICg0H6TSF#q8L{<|R{!oedU!$QM+u=y|mP_WR@9~}w`4i@EO z%f~t#JQM-|5gQ8!7Z39@5)_LH=*pk1sS7 z3@jW1JmLqJ3ljhX_?UiR!$89#eC&dP{$OHa0pPJIaM&ruRB@>|5KQsJo&Bjf)zr=6 z>w4eU0H`n@pqMb201?3b>@e|nvP$19=aB-F_43sfUHg`2@MG)pFV4eM1trA(T;D)Vex{e6uMVzx ztf!d*$xNbim*r8^x{{{v0QnUQN5PU_AMvD>1M|7{Dby#`sQn^e;YIK#yij9qk?K1P(g z-WX}W9%<*rK}VZ`2?L&wZMSPs)0o5#J-j1}DuZM|_xOVW9VWL2WFj@zMam4AfRAT* zl#0^7i%N>f8xpK8ON6T%FnGvVk`GgKkQ^@FgJ3J4SQ#(psWcZ>L?Xw~n4CRUUa;iY z&cHYW&VHn)3FwO${XrFEsB1N*;qTJ2ht}FoQq|}+<8-IFYL}X6F5RxU_;gXn;=XbZ zJ5=z6v{ZhAiM1s@h~!h(SyU^gvyNn0Z4SfX+OJ=2#KG4!@MTv zom8~{B)U$rOlWW(_PA!BRi7=9MNa&3W&jQo!xoaL7n+)3KH;dM8;mI;X9(M`ayJ0d z)i6!CFnG7!c!$CbjqF8z#!&@d&F+Xa{$|S>T?&vb@Wdzo3(JmLgKgD#tzZ<_g0G?D z6z4fZ3C6Bt#3M}0`dCuSL}jQYoSdd<_qm}&LD>_?)xy=Zt&O8Tp%AOQH{|y#o*E)~ z1r?5~g#fOr8_3m!fJ9dZ9u|T4`(-H6c!VvAw4pf0&U#;BD#m)bGfS21%Tq!q&U~48 zLlljT^#mQ?8194dJ0QnLd3U+HTjF(U;7sHU=^cjp#`*%~&pGHY@

pUz9*=J49jy6tdK#Ea4}SR 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 Date: Thu, 2 Dec 2021 19:00:37 -0800 Subject: [PATCH 065/184] Revert "Added picture for SPI documentation" This reverts commit 83ea3575881ee7b7d57fd9f4fda4671cc2bb4391. The Arduino Language reference is only used for the documentation of the Arduino programming language. Documentation of libraries is done in the individual library reference pages: https://www.arduino.cc/en/Reference/SPISettings --- Language/Functions/Communication/SPI/api.adoc | 269 ------------------ .../Communication/SPI/assets/ICSPHeader.jpg | Bin 15824 -> 0 bytes 2 files changed, 269 deletions(-) delete mode 100644 Language/Functions/Communication/SPI/api.adoc delete mode 100644 Language/Functions/Communication/SPI/assets/ICSPHeader.jpg diff --git a/Language/Functions/Communication/SPI/api.adoc b/Language/Functions/Communication/SPI/api.adoc deleted file mode 100644 index d9e8d455e..000000000 --- a/Language/Functions/Communication/SPI/api.adoc +++ /dev/null @@ -1,269 +0,0 @@ ---- -title: SPISettings -categories: [ "Functions" ] -subCategories: [ "Communication" ] ---- - -== SPISettings - -[float] -==== Description - -The SPISettings object is used to configure the SPI port for your SPI device. All 3 parameters are combined to a single SPISettings object, which is given to SPI.beginTransaction(). - -When all of your settings are constants, SPISettings should be used directly in SPI.beginTransaction(). See the syntax section below. For constants, this syntax results in smaller and faster code. - -If any of your settings are variables, you may create a SPISettings object to hold the 3 settings. Then you can give the object name to SPI.beginTransaction(). Creating a named SPISettings object may be more efficient when your settings are not constants, especially if the maximum speed is a variable computed or configured, rather than a number you type directly into your sketch. - -==== Syntax - ----- -SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0)) ----- - -NOTE: Best if all 3 settings are constants - ----- -SPISettings mySettting(speedMaximum, dataOrder, dataMode) ----- - -NOTE: Best when any setting is a variable - -==== Parameters - -speedMaximum: The maximum speed of communication. For a SPI chip rated up to 20 MHz, use 20000000. - -dataOrder: MSBFIRST or LSBFIRST - -dataMode : SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3 - -==== Returns - -None. - -[float] -=== `begin()` - -==== Description - -Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. - -==== Syntax - ----- -SPI.begin() ----- - -==== Parameters - -None - -==== Returns - -None - -[float] -=== `end()` - -==== Description - -Disables the SPI bus (leaving pin modes unchanged). - -==== Syntax - ----- -SPI.end() ----- - -==== Parameters - -None - -==== Returns - -None - -[float] -=== `beginTransaction()` - -==== Description - -Initializes the SPI bus using the defined SPISettings. - -==== Syntax - ----- -SPI.beginTransaction(mySettings); ----- - -==== Parameters - -mySettings: the chosen settings according to SPISettings. - -==== Returns - -None. - -[float] -=== `endTransaction()` - -==== Description - -Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus. - -==== Syntax - ----- -SPI.endTransaction() ----- - -==== Parameters - -None. - -==== Returns - -None. - -[float] -=== `setBitOrder()` - -==== Description - -This function should not be used in new projects. Use SPISettings with SPI.beginTransaction() to configure SPI parameters. - -Sets the order of the bits shifted out of and into the SPI bus, either LSBFIRST (least-significant bit first) or MSBFIRST (most-significant bit first). - -==== Syntax - ----- -SPI.setBitOrder(order) ----- - -==== Parameters - -order: either LSBFIRST or MSBFIRST - -==== Returns - -None - -[float] -=== `setClockDivider()` - -==== Description - -This function should not be used in new projects. Use SPISettings with SPI.beginTransaction() to configure SPI parameters. - -Sets the SPI clock divider relative to the system clock. On AVR based boards, the dividers available are 2, 4, 8, 16, 32, 64 or 128. The default setting is SPI_CLOCK_DIV4, which sets the SPI clock to one-quarter the frequency of the system clock (4 Mhz for the boards at 16 MHz). - -===== Arduino Due -On the Due, the system clock can be divided by values from 1 to 255. The default value is 21, which sets the clock to 4 MHz like other Arduino boards. - -==== Syntax - ----- -SPI.setClockDivider(divider) ----- - -==== Parameters - -divider (On AVR boards): - -* SPI_CLOCK_DIV2 -* SPI_CLOCK_DIV4 -* SPI_CLOCK_DIV8 -* SPI_CLOCK_DIV16 -* SPI_CLOCK_DIV32 -* SPI_CLOCK_DIV64 -* SPI_CLOCK_DIV128 - -slaveSelectPin: - -* slave device SS pin (Arduino Due only) - -divider (Arduino Due only): - -* a number from 1 to 255 (Arduino Due only) - -==== Returns - -None - -[float] -=== `setDataMode()` - -==== Description - -This function should not be used in new projects. Use SPISettings with SPI.beginTransaction() to configure SPI parameters. - -Sets the SPI data mode: that is, clock polarity and phase. See the Wikipedia article on SPI for details. - -==== Syntax - ----- -SPI.setDataMode(mode) ----- - -==== Parameters - -mode: - -* SPI_MODE0 -* SPI_MODE1 -* SPI_MODE2 -* SPI_MODE3 - -slaveSelectPin - -* slave device SS pin (Arduino Due only) - -==== Returns - -None - -[float] -=== `transfer()` - -==== Description - -SPI transfer is based on a simultaneous send and receive: the received data is returned in receivedVal (or receivedVal16). In case of buffer transfers the received data is stored in the buffer in-place (the old data is replaced with the data received). - -==== Syntax - ----- -receivedVal = SPI.transfer(val) -receivedVal16 = SPI.transfer16(val16) -SPI.transfer(buffer, size) ----- - -==== Parameters - -* val: the byte to send out over the bus -* val16: the two bytes variable to send out over the bus -* buffer: the array of data to be transferred - -==== Returns - -the received data - -[float] -=== `usingInterrupt()` - -==== Description - -If your program will perform SPI transactions within an interrupt, call this function to register the interrupt number or name with the SPI library. This allows SPI.beginTransaction() to prevent usage conflicts. Note that the interrupt specified in the call to usingInterrupt() will be disabled on a call to beginTransaction() and re-enabled in endTransaction(). - -==== Syntax - ----- -SPI.usingInterrupt(interruptNumber) ----- - -==== Parameters - -interruptNumber: the associated interrupt number. - -==== Returns - -None. diff --git a/Language/Functions/Communication/SPI/assets/ICSPHeader.jpg b/Language/Functions/Communication/SPI/assets/ICSPHeader.jpg deleted file mode 100644 index e2c463ed4918425984f94591e46aed8cbcb10a73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15824 zcmbt*RZv{Pm-paK@ZjzibZ~bK?#@7P3rui=ySoKqybP+PypGF2k^cQkoeE+|J42i@_z#O&*AqT045^9 z2=E94MG1h$go43@dLICg0H6TSF#q8L{<|R{!oedU!$QM+u=y|mP_WR@9~}w`4i@EO z%f~t#JQM-|5gQ8!7Z39@5)_LH=*pk1sS7 z3@jW1JmLqJ3ljhX_?UiR!$89#eC&dP{$OHa0pPJIaM&ruRB@>|5KQsJo&Bjf)zr=6 z>w4eU0H`n@pqMb201?3b>@e|nvP$19=aB-F_43sfUHg`2@MG)pFV4eM1trA(T;D)Vex{e6uMVzx ztf!d*$xNbim*r8^x{{{v0QnUQN5PU_AMvD>1M|7{Dby#`sQn^e;YIK#yij9qk?K1P(g z-WX}W9%<*rK}VZ`2?L&wZMSPs)0o5#J-j1}DuZM|_xOVW9VWL2WFj@zMam4AfRAT* zl#0^7i%N>f8xpK8ON6T%FnGvVk`GgKkQ^@FgJ3J4SQ#(psWcZ>L?Xw~n4CRUUa;iY z&cHYW&VHn)3FwO${XrFEsB1N*;qTJ2ht}FoQq|}+<8-IFYL}X6F5RxU_;gXn;=XbZ zJ5=z6v{ZhAiM1s@h~!h(SyU^gvyNn0Z4SfX+OJ=2#KG4!@MTv zom8~{B)U$rOlWW(_PA!BRi7=9MNa&3W&jQo!xoaL7n+)3KH;dM8;mI;X9(M`ayJ0d z)i6!CFnG7!c!$CbjqF8z#!&@d&F+Xa{$|S>T?&vb@Wdzo3(JmLgKgD#tzZ<_g0G?D z6z4fZ3C6Bt#3M}0`dCuSL}jQYoSdd<_qm}&LD>_?)xy=Zt&O8Tp%AOQH{|y#o*E)~ z1r?5~g#fOr8_3m!fJ9dZ9u|T4`(-H6c!VvAw4pf0&U#;BD#m)bGfS21%Tq!q&U~48 zLlljT^#mQ?8194dJ0QnLd3U+HTjF(U;7sHU=^cjp#`*%~&pGHY@

pUz9*=J49jy6tdK#Ea4}SR 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 Date: Tue, 14 Dec 2021 14:59:11 +0100 Subject: [PATCH 066/184] Update length.adoc --- Language/Variables/Data Types/String/Functions/length.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/String/Functions/length.adoc b/Language/Variables/Data Types/String/Functions/length.adoc index a0b644b42..3ced638e9 100644 --- a/Language/Variables/Data Types/String/Functions/length.adoc +++ b/Language/Variables/Data Types/String/Functions/length.adoc @@ -34,7 +34,7 @@ Returns the length of the String, in characters. (Note that this doesn't include [float] === Returns -The length of the String in characters. +The length of the String in characters as an unsigned int. -- // OVERVIEW SECTION ENDS From a1ccc71b7b0f5890f32da743d337ad5246667cb6 Mon Sep 17 00:00:00 2001 From: Kristoffer Engdahl Date: Mon, 20 Dec 2021 11:02:40 +0100 Subject: [PATCH 067/184] Update Language/Variables/Data Types/String/Functions/length.adoc Co-authored-by: per1234 --- Language/Variables/Data Types/String/Functions/length.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/String/Functions/length.adoc b/Language/Variables/Data Types/String/Functions/length.adoc index 3ced638e9..d3703282e 100644 --- a/Language/Variables/Data Types/String/Functions/length.adoc +++ b/Language/Variables/Data Types/String/Functions/length.adoc @@ -34,7 +34,7 @@ Returns the length of the String, in characters. (Note that this doesn't include [float] === Returns -The length of the String in characters as an unsigned int. +The length of the String in characters. Data type: `unsigned int`. -- // OVERVIEW SECTION ENDS From 897ef471908c2e27a8ba30d98cf9bd125aff68cf Mon Sep 17 00:00:00 2001 From: YClayton <94257246+YClayton@users.noreply.github.com> Date: Fri, 24 Dec 2021 11:40:40 -0600 Subject: [PATCH 068/184] Update compoundMultiplication.adoc Change Example Code from: x = 2; x *= 2; // x now contains 4 ---- Change it to: x = 2; x *= 3; // x now contains 6 ---- Just makes it a little clearer, since 2+2=4 and 2*2=4. Too many twos. --- .../Structure/Compound Operators/compoundMultiplication.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Structure/Compound Operators/compoundMultiplication.adoc b/Language/Structure/Compound Operators/compoundMultiplication.adoc index b2ec543ab..cd5f56582 100644 --- a/Language/Structure/Compound Operators/compoundMultiplication.adoc +++ b/Language/Structure/Compound Operators/compoundMultiplication.adoc @@ -47,7 +47,7 @@ This is a convenient shorthand to perform multiplication of a variable with anot [source,arduino] ---- x = 2; -x *= 2; // x now contains 4 +x *= 3; // x now contains 6 ---- From 11c51188575cb1070c794acb249668016765e641 Mon Sep 17 00:00:00 2001 From: Stefan Lenz Date: Sun, 26 Dec 2021 19:05:52 +0100 Subject: [PATCH 069/184] Update PROGMEM.adoc The use of pgm_read_word() in the example is wrong and only works on 16 bit systems. We are dealing with a pointer here so the correct function would be pgm_read_ptr(). --- Language/Variables/Utilities/PROGMEM.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Utilities/PROGMEM.adoc b/Language/Variables/Utilities/PROGMEM.adoc index b483ad5fe..7dc5e44e7 100644 --- a/Language/Variables/Utilities/PROGMEM.adoc +++ b/Language/Variables/Utilities/PROGMEM.adoc @@ -151,7 +151,7 @@ void loop() { for (int i = 0; i < 6; i++) { - strcpy_P(buffer, (char *)pgm_read_word(&(string_table[i]))); // Necessary casts and dereferencing, just copy. + strcpy_P(buffer, (char *)pgm_read_ptr(&(string_table[i]))); // Necessary casts and dereferencing, just copy. Serial.println(buffer); delay(500); } From d74e42bad35a23300e90dee83b58d6ca06390a4e Mon Sep 17 00:00:00 2001 From: "Oscar (Coda)" <58069739+Core-l@users.noreply.github.com> Date: Mon, 10 Jan 2022 18:17:43 +0000 Subject: [PATCH 070/184] Strange results in floating point 6.0 / 3.0 != 2.0 is an incorrect example because floats can represent all three numbers perfectly, so the result is equal. 9.0 / 0.3 != 30.0 is a better example, it produces the correct result in double precision but not in single precision. --- Language/Variables/Data Types/float.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/float.adoc b/Language/Variables/Data Types/float.adoc index 8882397ed..fd89b97a5 100644 --- a/Language/Variables/Data Types/float.adoc +++ b/Language/Variables/Data Types/float.adoc @@ -67,7 +67,7 @@ If doing math with floats, you need to add a decimal point, otherwise it will be The float data type has only 6-7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point. Unlike other platforms, where you can get more precision by using a double (e.g. up to 15 digits), on the Arduino, double is the same size as float. -Floating point numbers are not exact, and may yield strange results when compared. For example 6.0 / 3.0 may not equal 2.0. You should instead check that the absolute value of the difference between the numbers is less than some small number. +Floating point numbers are not exact, and may yield strange results when compared. For example 9.0 / 0.3 may not quite equal 30.0. You should instead check that the absolute value of the difference between the numbers is less than some small number. Conversion from floating point to integer math results in truncation: [source,arduino] From d57814d89f503317c0e4f033da62fe98774141df Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 18 Jan 2022 16:22:28 +1300 Subject: [PATCH 071/184] Mention millis() not ticking every millisecond Mention millis() ticking every 1.024 mS, skipping a value every 41 or 42, and maybe using micros for short accurate timings. --- Language/Functions/Time/millis.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Language/Functions/Time/millis.adoc b/Language/Functions/Time/millis.adoc index 7ff5f7624..d1a2917a6 100644 --- a/Language/Functions/Time/millis.adoc +++ b/Language/Functions/Time/millis.adoc @@ -66,6 +66,10 @@ void loop() { === Notes and Warnings Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. +Note that millis() is incremented (for 16 MHz AVR chips and some others) every 1.024 milliseconds, then incrementing by 2 (rather than 1) every 41 or 42 ticks, to pull it back into synch; thus some millis() values are skipped. For accurate timing over short intervals, consider using micros(). + +Note that millis() will wrap around to 0 after about 49 days (micros in about 71 minutes). + -- // HOW TO USE SECTION ENDS From a6035d7ef4b944998deafadb12df6f5677f0045b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 19 Jan 2022 15:50:55 +0100 Subject: [PATCH 072/184] Migrate & convert SPI docs from older platform --- Language/Functions/Communication/SPI.adoc | 52 +++++++++++++++++++ .../Communication/SPI/SPISettings.adoc | 42 +++++++++++++++ .../Functions/Communication/SPI/begin.adoc | 33 ++++++++++++ .../Communication/SPI/beginTransaction.adoc | 33 ++++++++++++ Language/Functions/Communication/SPI/end.adoc | 33 ++++++++++++ .../Communication/SPI/endTransaction.adoc | 33 ++++++++++++ .../Communication/SPI/setBitOrder.adoc | 35 +++++++++++++ .../Communication/SPI/setClockDivider.adoc | 47 +++++++++++++++++ .../Communication/SPI/setDataMode.adoc | 41 +++++++++++++++ .../Functions/Communication/SPI/transfer.adoc | 40 ++++++++++++++ .../Communication/SPI/usingInterrupt.adoc | 33 ++++++++++++ 11 files changed, 422 insertions(+) create mode 100644 Language/Functions/Communication/SPI.adoc create mode 100644 Language/Functions/Communication/SPI/SPISettings.adoc create mode 100644 Language/Functions/Communication/SPI/begin.adoc create mode 100644 Language/Functions/Communication/SPI/beginTransaction.adoc create mode 100644 Language/Functions/Communication/SPI/end.adoc create mode 100644 Language/Functions/Communication/SPI/endTransaction.adoc create mode 100644 Language/Functions/Communication/SPI/setBitOrder.adoc create mode 100644 Language/Functions/Communication/SPI/setClockDivider.adoc create mode 100644 Language/Functions/Communication/SPI/setDataMode.adoc create mode 100644 Language/Functions/Communication/SPI/transfer.adoc create mode 100644 Language/Functions/Communication/SPI/usingInterrupt.adoc diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc new file mode 100644 index 000000000..b77499d5c --- /dev/null +++ b/Language/Functions/Communication/SPI.adoc @@ -0,0 +1,52 @@ +--- +title: SPI +categories: [ "Functions" ] +subCategories: [ "Communication" ] +--- + + += SPI + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + + +This library allows you to communicate with SPI devices, with the Arduino as the controller device. This library is bundled with every Arduino platform (avr, megaavr, mbed, samd, sam, arc32), so *you do not need to install* the library separately. + +To use this library + +`#include ` + +To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/learn/communication/spi[Arduino & Serial Peripheral Interface (SPI)] guide. + +-- +// OVERVIEW SECTION ENDS + + +// FUNCTIONS SECTION STARTS +[#functions] +-- + +''' + +[float] +=== Functions +link:../SPI/SPISettings[SPISettings] + +link:../SPI/begin[begin()] + +link:../SPI/beginTransaction[beginTransaction()] + +link:../SPI/end[end()] + +link:../SPI/setBitOrder[setBitOrder()] + +link:../SPI/setClockDivider[setClockDivider()] + +link:../SPI/setDataMode[setDataMode()] + +link:../SPI/transfer[transfer()] + +link:../SPI/usingInterrupt[usingInterrupt()] + +''' + +-- +// SEEALSO SECTION ENDS diff --git a/Language/Functions/Communication/SPI/SPISettings.adoc b/Language/Functions/Communication/SPI/SPISettings.adoc new file mode 100644 index 000000000..d8c7351af --- /dev/null +++ b/Language/Functions/Communication/SPI/SPISettings.adoc @@ -0,0 +1,42 @@ +--- +title: SPISettings +--- + += SPISettings + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +The `SPISettings` object is used to configure the SPI port for your SPI device. All 3 parameters are combined to a single `SPISettings` object, which is given to `SPI.beginTransaction()`. + +When all of your settings are constants, SPISettings should be used directly in `SPI.beginTransaction()`. See the syntax section below. For constants, this syntax results in smaller and faster code. + +If any of your settings are variables, you may create a SPISettings object to hold the 3 settings. Then you can give the object name to SPI.beginTransaction(). Creating a named SPISettings object may be more efficient when your settings are not constants, especially if the maximum speed is a variable computed or configured, rather than a number you type directly into your sketch. + +[float] +=== Syntax +`SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0))` +Note: Best if all 3 settings are constants + +`SPISettings mySettting(speedMaximum, dataOrder, dataMode)` +Note: Best when any setting is a variable'' + + +[float] +=== Parameters +`speedMaximum`: The maximum speed of communication. For a SPI chip rated up to 20 MHz, use 20000000. + +`dataOrder`: MSBFIRST or LSBFIRST + +`dataMode`: SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3 + + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/begin.adoc b/Language/Functions/Communication/SPI/begin.adoc new file mode 100644 index 000000000..757e57c6c --- /dev/null +++ b/Language/Functions/Communication/SPI/begin.adoc @@ -0,0 +1,33 @@ +--- +title: SPI.begin() +--- + += SPI.begin() + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. + + +[float] +=== Syntax +`SPI.begin()` + + +[float] +=== Parameters +None. + + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/beginTransaction.adoc b/Language/Functions/Communication/SPI/beginTransaction.adoc new file mode 100644 index 000000000..6c9f63b7f --- /dev/null +++ b/Language/Functions/Communication/SPI/beginTransaction.adoc @@ -0,0 +1,33 @@ +--- +title: SPI.beginTransaction() +--- + += SPI.beginTransaction() + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +Initializes the SPI bus using the defined link:SPISettings[SPISettings]. + + +[float] +=== Syntax +`SPI.beginTransaction(mySettings)` + + +[float] +=== Parameters +mySettings: the chosen settings according to link:SPISettings[SPISettings]. + + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/end.adoc b/Language/Functions/Communication/SPI/end.adoc new file mode 100644 index 000000000..76eef8025 --- /dev/null +++ b/Language/Functions/Communication/SPI/end.adoc @@ -0,0 +1,33 @@ +--- +title: SPI.end() +--- + += SPI.end() + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +Disables the SPI bus (leaving pin modes unchanged). + + +[float] +=== Syntax +`SPI.end()` + + +[float] +=== Parameters +None. + + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/endTransaction.adoc b/Language/Functions/Communication/SPI/endTransaction.adoc new file mode 100644 index 000000000..4bf8ec891 --- /dev/null +++ b/Language/Functions/Communication/SPI/endTransaction.adoc @@ -0,0 +1,33 @@ +--- +title: SPI.endTransaction() +--- + += SPI.endTransaction() + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus. + + +[float] +=== Syntax +`SPI.endTransaction()` + + +[float] +=== Parameters +None. + + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/setBitOrder.adoc b/Language/Functions/Communication/SPI/setBitOrder.adoc new file mode 100644 index 000000000..b1e09d264 --- /dev/null +++ b/Language/Functions/Communication/SPI/setBitOrder.adoc @@ -0,0 +1,35 @@ +--- +title: SPI.setBitOrder() +--- + += SPI.setBitOrder() + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function should not be used in new projects. Use link:SPISettings[SPISettings]. with link:beginTransaction[SPI.beginTransaction()]. to configure SPI parameters. + +Sets the order of the bits shifted out of and into the SPI bus, either LSBFIRST (least-significant bit first) or MSBFIRST (most-significant bit first). + + +[float] +=== Syntax +`SPI.setBitOrder(order)` + + +[float] +=== Parameters +order: either LSBFIRST or MSBFIRST + + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/setClockDivider.adoc b/Language/Functions/Communication/SPI/setClockDivider.adoc new file mode 100644 index 000000000..2aad770e1 --- /dev/null +++ b/Language/Functions/Communication/SPI/setClockDivider.adoc @@ -0,0 +1,47 @@ +--- +title: SPI.setClockDivider() +--- + += SPI.setClockDivider() + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function should not be used in new projects. Use link:SPISettings[SPISettings]. with link:beginTransaction[SPI.beginTransaction()]. to configure SPI parameters. + +Sets the SPI clock divider relative to the system clock. On AVR based boards, the dividers available are 2, 4, 8, 16, 32, 64 or 128. The default setting is SPI_CLOCK_DIV4, which sets the SPI clock to one-quarter the frequency of the system clock (4 Mhz for the boards at 16 MHz). + +*For Arduino Due:* On the Due, the system clock can be divided by values from 1 to 255. The default value is 21, which sets the clock to 4 MHz like other Arduino boards. + + +[float] +=== Syntax +`SPI.setClockDivider(divider)` + + +[float] +=== Parameters + +divider (only AVR boards): +* SPI_CLOCK_DIV2 +* SPI_CLOCK_DIV4 +* SPI_CLOCK_DIV8 +* SPI_CLOCK_DIV16 +* SPI_CLOCK_DIV32 +* SPI_CLOCK_DIV64 +* SPI_CLOCK_DIV128 + +chipSelectPin: peripheral device CS pin (Arduino Due only) +divider: a number from 1 to 255 (Arduino Due only) + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/setDataMode.adoc b/Language/Functions/Communication/SPI/setDataMode.adoc new file mode 100644 index 000000000..4a0472fa1 --- /dev/null +++ b/Language/Functions/Communication/SPI/setDataMode.adoc @@ -0,0 +1,41 @@ +--- +title: SPI.setDataMode() +--- + += SPI.setDataMode() + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function should not be used in new projects. Use link:SPISettings[SPISettings]. with link:beginTransaction[SPI.beginTransaction()]. to configure SPI parameters. + +Sets the SPI data mode: that is, clock polarity and phase. See the Wikipedia article on http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus:[SPI] for details. + +[float] +=== Syntax +`SPI.setDataMode(mode)` + + +[float] +=== Parameters + +mode: + +* SPI_MODE0 +* SPI_MODE1 +* SPI_MODE2 +* SPI_MODE3 + + +chipSelectPin - peripheral device CS pin (Arduino Due only) + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/transfer.adoc b/Language/Functions/Communication/SPI/transfer.adoc new file mode 100644 index 000000000..ff59a3b3c --- /dev/null +++ b/Language/Functions/Communication/SPI/transfer.adoc @@ -0,0 +1,40 @@ +--- +title: SPI.transfer() +--- + += SPI.transfer() + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + +SPI transfer is based on a simultaneous send and receive: the received data is returned in receivedVal (or receivedVal16). In case of buffer transfers the received data is stored in the buffer in-place (the old data is replaced with the data received). + +[float] +=== Syntax + +`receivedVal = SPI.transfer(val)` + +`receivedVal16 = SPI.transfer16(val16)` + +`SPI.transfer(buffer, size)` + + +[float] +=== Parameters + +* val: the byte to send out over the bus +* val16: the two bytes variable to send out over the bus +* buffer: the array of data to be transferred + + +[float] +=== Returns +The received data. + +-- +// OVERVIEW SECTION ENDS + diff --git a/Language/Functions/Communication/SPI/usingInterrupt.adoc b/Language/Functions/Communication/SPI/usingInterrupt.adoc new file mode 100644 index 000000000..7769ba39d --- /dev/null +++ b/Language/Functions/Communication/SPI/usingInterrupt.adoc @@ -0,0 +1,33 @@ +--- +title: SPI.usingInterrupt() +--- + += SPI.usingInterrupt() + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + +If your program will perform SPI transactions within an interrupt, call this function to register the interrupt number or name with the SPI library. This allows `SPI.beginTransaction()` to prevent usage conflicts. Note that the interrupt specified in the call to usingInterrupt() will be disabled on a call to `beginTransaction()` and re-enabled in `endTransaction().` + +[float] +=== Syntax + +`SPI.usingInterrupt(interruptNumber)` + + +[float] +=== Parameters + +interruptNumber: the associated interrupt number. + +[float] +=== Returns +None. + +-- +// OVERVIEW SECTION ENDS + From b92545196f62f1ce4b6385419b10a84e9ebba6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 21 Jan 2022 17:59:12 +0100 Subject: [PATCH 073/184] Update links with lowercase --- Language/Functions/Communication/SPI.adoc | 18 +++++++++--------- .../Communication/SPI/SPISettings.adoc | 3 ++- .../Communication/SPI/beginTransaction.adoc | 4 ++-- .../Communication/SPI/setBitOrder.adoc | 2 +- .../Communication/SPI/setClockDivider.adoc | 7 ++++--- .../Communication/SPI/setDataMode.adoc | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index b77499d5c..7d8f82036 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -36,15 +36,15 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le [float] === Functions -link:../SPI/SPISettings[SPISettings] + -link:../SPI/begin[begin()] + -link:../SPI/beginTransaction[beginTransaction()] + -link:../SPI/end[end()] + -link:../SPI/setBitOrder[setBitOrder()] + -link:../SPI/setClockDivider[setClockDivider()] + -link:../SPI/setDataMode[setDataMode()] + -link:../SPI/transfer[transfer()] + -link:../SPI/usingInterrupt[usingInterrupt()] +link:../spi/spisettings[SPISettings] + +link:../spi/begin[begin()] + +link:../spi/begintransaction[beginTransaction()] + +link:../spi/end[end()] + +link:../spi/setbitorder[setBitOrder()] + +link:../spi/setclockdivider[setClockDivider()] + +link:../spi/setdatamode[setDataMode()] + +link:../spi/transfer[transfer()] + +link:../spi/usinginterrupt[usingInterrupt()] ''' diff --git a/Language/Functions/Communication/SPI/SPISettings.adoc b/Language/Functions/Communication/SPI/SPISettings.adoc index d8c7351af..a0586c8b6 100644 --- a/Language/Functions/Communication/SPI/SPISettings.adoc +++ b/Language/Functions/Communication/SPI/SPISettings.adoc @@ -22,12 +22,13 @@ If any of your settings are variables, you may create a SPISettings object to ho `SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0))` Note: Best if all 3 settings are constants -`SPISettings mySettting(speedMaximum, dataOrder, dataMode)` +`SPISettings mySetting(speedMaximum, dataOrder, dataMode)` Note: Best when any setting is a variable'' [float] === Parameters + `speedMaximum`: The maximum speed of communication. For a SPI chip rated up to 20 MHz, use 20000000. + `dataOrder`: MSBFIRST or LSBFIRST + `dataMode`: SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3 diff --git a/Language/Functions/Communication/SPI/beginTransaction.adoc b/Language/Functions/Communication/SPI/beginTransaction.adoc index 6c9f63b7f..3b5147aff 100644 --- a/Language/Functions/Communication/SPI/beginTransaction.adoc +++ b/Language/Functions/Communication/SPI/beginTransaction.adoc @@ -11,7 +11,7 @@ title: SPI.beginTransaction() [float] === Description -Initializes the SPI bus using the defined link:SPISettings[SPISettings]. +Initializes the SPI bus using the defined link:../spisettings[SPISettings]. [float] @@ -21,7 +21,7 @@ Initializes the SPI bus using the defined link:SPISettings[SPISettings]. [float] === Parameters -mySettings: the chosen settings according to link:SPISettings[SPISettings]. +mySettings: the chosen settings according to link:../spisettings[SPISettings]. [float] diff --git a/Language/Functions/Communication/SPI/setBitOrder.adoc b/Language/Functions/Communication/SPI/setBitOrder.adoc index b1e09d264..c67d40c1e 100644 --- a/Language/Functions/Communication/SPI/setBitOrder.adoc +++ b/Language/Functions/Communication/SPI/setBitOrder.adoc @@ -11,7 +11,7 @@ title: SPI.setBitOrder() [float] === Description -This function should not be used in new projects. Use link:SPISettings[SPISettings]. with link:beginTransaction[SPI.beginTransaction()]. to configure SPI parameters. +This function should not be used in new projects. Use link:../spisettings[SPISettings]. with link:../begintransaction[SPI.beginTransaction()]. to configure SPI parameters. Sets the order of the bits shifted out of and into the SPI bus, either LSBFIRST (least-significant bit first) or MSBFIRST (most-significant bit first). diff --git a/Language/Functions/Communication/SPI/setClockDivider.adoc b/Language/Functions/Communication/SPI/setClockDivider.adoc index 2aad770e1..edb835c99 100644 --- a/Language/Functions/Communication/SPI/setClockDivider.adoc +++ b/Language/Functions/Communication/SPI/setClockDivider.adoc @@ -11,7 +11,7 @@ title: SPI.setClockDivider() [float] === Description -This function should not be used in new projects. Use link:SPISettings[SPISettings]. with link:beginTransaction[SPI.beginTransaction()]. to configure SPI parameters. +This function should not be used in new projects. Use link:../spisettings[SPISettings]. with link:../begintransaction[SPI.beginTransaction()]. to configure SPI parameters. Sets the SPI clock divider relative to the system clock. On AVR based boards, the dividers available are 2, 4, 8, 16, 32, 64 or 128. The default setting is SPI_CLOCK_DIV4, which sets the SPI clock to one-quarter the frequency of the system clock (4 Mhz for the boards at 16 MHz). @@ -27,6 +27,7 @@ Sets the SPI clock divider relative to the system clock. On AVR based boards, th === Parameters divider (only AVR boards): + * SPI_CLOCK_DIV2 * SPI_CLOCK_DIV4 * SPI_CLOCK_DIV8 @@ -35,8 +36,8 @@ divider (only AVR boards): * SPI_CLOCK_DIV64 * SPI_CLOCK_DIV128 -chipSelectPin: peripheral device CS pin (Arduino Due only) -divider: a number from 1 to 255 (Arduino Due only) +*chipSelectPin*: peripheral device CS pin (Arduino Due only) +*divider*: a number from 1 to 255 (Arduino Due only) [float] === Returns diff --git a/Language/Functions/Communication/SPI/setDataMode.adoc b/Language/Functions/Communication/SPI/setDataMode.adoc index 4a0472fa1..4089e5e89 100644 --- a/Language/Functions/Communication/SPI/setDataMode.adoc +++ b/Language/Functions/Communication/SPI/setDataMode.adoc @@ -10,7 +10,7 @@ title: SPI.setDataMode() [float] === Description -This function should not be used in new projects. Use link:SPISettings[SPISettings]. with link:beginTransaction[SPI.beginTransaction()]. to configure SPI parameters. +This function should not be used in new projects. Use link:../spisettings[SPISettings]. with link:../begintransaction[SPI.beginTransaction()]. to configure SPI parameters. Sets the SPI data mode: that is, clock polarity and phase. See the Wikipedia article on http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus:[SPI] for details. From 1c575d03fe52a00f3090b2609c172fb0b2f1d58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 14 Feb 2022 11:45:06 +0100 Subject: [PATCH 074/184] Add Wire Documentation --- Language/Functions/Communication/Wire.adoc | 78 +++++++++++++ .../Communication/Wire/available.adoc | 30 +++++ .../Functions/Communication/Wire/begin.adoc | 31 ++++++ .../Communication/Wire/beginTransmission.adoc | 28 +++++ .../Wire/clearWireTimeoutFlag.adoc | 37 ++++++ .../Functions/Communication/Wire/end.adoc | 31 ++++++ .../Communication/Wire/endTransmission.adoc | 34 ++++++ .../Wire/getWireTimeoutFlag.adoc | 37 ++++++ .../Communication/Wire/onReceive.adoc | 30 +++++ .../Communication/Wire/onRequest.adoc | 30 +++++ .../Functions/Communication/Wire/read.adoc | 54 +++++++++ .../Communication/Wire/requestFrom.adoc | 33 ++++++ .../Communication/Wire/setClock.adoc | 28 +++++ .../Communication/Wire/setWireTimeout.adoc | 105 ++++++++++++++++++ .../Functions/Communication/Wire/write.adoc | 61 ++++++++++ 15 files changed, 647 insertions(+) create mode 100644 Language/Functions/Communication/Wire.adoc create mode 100644 Language/Functions/Communication/Wire/available.adoc create mode 100644 Language/Functions/Communication/Wire/begin.adoc create mode 100644 Language/Functions/Communication/Wire/beginTransmission.adoc create mode 100644 Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc create mode 100644 Language/Functions/Communication/Wire/end.adoc create mode 100644 Language/Functions/Communication/Wire/endTransmission.adoc create mode 100644 Language/Functions/Communication/Wire/getWireTimeoutFlag.adoc create mode 100644 Language/Functions/Communication/Wire/onReceive.adoc create mode 100644 Language/Functions/Communication/Wire/onRequest.adoc create mode 100644 Language/Functions/Communication/Wire/read.adoc create mode 100644 Language/Functions/Communication/Wire/requestFrom.adoc create mode 100644 Language/Functions/Communication/Wire/setClock.adoc create mode 100644 Language/Functions/Communication/Wire/setWireTimeout.adoc create mode 100644 Language/Functions/Communication/Wire/write.adoc diff --git a/Language/Functions/Communication/Wire.adoc b/Language/Functions/Communication/Wire.adoc new file mode 100644 index 000000000..943ba09f3 --- /dev/null +++ b/Language/Functions/Communication/Wire.adoc @@ -0,0 +1,78 @@ +--- +title: Wire +categories: [ "Functions" ] +subCategories: [ "Communication" ] +--- + + += Wire + + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + + +This library allows you to communicate with I2C/TWI devices. On the Arduino boards with the R3 layout (1.0 pinout), the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. The Arduino Due has two I2C/TWI interfaces SDA1 and SCL1 are near to the AREF pin and the additional one is on pins 20 and 21. + +As a reference the table below shows where TWI pins are located on various Arduino boards. + +[cols="1,1"] +|=== +|Board +|I2C/TWI pins + +|UNO, Ethernet +|A4 (SDA), A5 (SCL) + +|Mega2560 +|20 (SDA), 21 (SCL) + +|Leonardo +|20 (SDA), 21 (SCL), SDA1, SCL1 +|=== + + +As of Arduino 1.0, the library inherits from the Stream functions, making it consistent with other read/write libraries. Because of this, `send()` and `receive()` have been replaced with `read()` and `write()`. + +Recent versions of the Wire library can use timeouts to prevent a lockup in the face of certain problems on the bus, but this is not enabled by default (yet) in current versions. It is recommended to always enable these timeouts when using the Wire library. See the Wire.setWireTimeout function for more details. + +*Note:* There are both 7 and 8-bit versions of I2C addresses. 7 bits identify the device, and the eighth bit determines if it's being written to or read from. The Wire library uses 7 bit addresses throughout. If you have a datasheet or sample code that uses 8-bit address, you'll want to drop the low bit (i.e. shift the value one bit to the right), yielding an address between 0 and 127. However the addresses from 0 to 7 are not used because are reserved so the first address that can be used is 8. Please note that a pull-up resistor is needed when connecting SDA/SCL pins. Please refer to the examples for more information. MEGA 2560 board has pull-up resistors on pins 20 and 21 onboard. + +*The Wire library implementation uses a 32 byte buffer, therefore any communication should be within this limit. Exceeding bytes in a single transmission will just be dropped.* + +To use this library: + +`#include ` + +-- +// OVERVIEW SECTION ENDS + +//FUNCTION SECTION STARTS +[#functions] +-- + +''' +[float] +=== Functions +link:../wire/begin[begin()] + +link:../wire/end[end()] + +link:../wire/requestfrom[requestFrom()] + +link:../wire/begintransmission[beginTransmission()] + +link:../wire/write[write()] + +link:../wire/available[available()] + +link:../wire/read[read()] + +link:../wire/setclock[setClock()] + +link:../wire/onreceive[onReceive()] + +link:../wire/onrequest[onRequest()] + +link:../wire/setwiretimeout[setWireTimeout()] + +link:../wire/clearwiretimeoutflag[clearWireTimeoutFlag()] + +link:../wire/getwiretimeoutflag[getWireTimeoutFlag()] + +''' + +-- +// FUNCTION SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/available.adoc b/Language/Functions/Communication/Wire/available.adoc new file mode 100644 index 000000000..db375e9ee --- /dev/null +++ b/Language/Functions/Communication/Wire/available.adoc @@ -0,0 +1,30 @@ +--- +title: available() +--- + += available + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function returns the number of bytes available for retrieval with `read()`. This function should be called on a controller device after a call to `requestFrom()` or on a peripheral inside the `onReceive()` handler. `available()` inherits from the Stream utility class. + +[float] +=== Syntax +`Wire.available()` + +[float] +=== Parameters + +None. + +[float] +=== Returns + +The number of bytes available for reading. + +-- +//OVERVIEW SECTION STARTS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/begin.adoc b/Language/Functions/Communication/Wire/begin.adoc new file mode 100644 index 000000000..cbd0dea14 --- /dev/null +++ b/Language/Functions/Communication/Wire/begin.adoc @@ -0,0 +1,31 @@ +--- +title: begin() +--- += begin + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + +This function initializes the Wire library and join the I2C bus as a controller or a peripheral. This function should normally be called only once. + +[float] +=== Syntax + +`Wire.begin()` + +`Wire.begin(address)` + +[float] +=== Parameters +* _address_: the 7-bit slave address (optional); if not specified, join the bus as a controller device. + +[float] +=== Returns +None. +-- + +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/beginTransmission.adoc b/Language/Functions/Communication/Wire/beginTransmission.adoc new file mode 100644 index 000000000..ffc686af5 --- /dev/null +++ b/Language/Functions/Communication/Wire/beginTransmission.adoc @@ -0,0 +1,28 @@ +--- +title: beginTransmission() +--- + += beginTransmission + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function begins a transmission to the I2C peripheral device with the given address. Subsequently, queue bytes for transmission with the `write()` function and transmit them by calling `endTransmission()`. + +[float] +=== Syntax + +`Wire.beginTransmission(address)` + +[float] +=== Parameters +* _address_: the 7-bit address of the device to transmit to. + +[float] +=== Returns +None. +-- +//OVERVIEW SECTION ENDS diff --git a/Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc b/Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc new file mode 100644 index 000000000..b5a44711f --- /dev/null +++ b/Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc @@ -0,0 +1,37 @@ +--- +title: clearWireTimeoutFlag() +--- += clearWireTimeoutFlag + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + +Clears the timeout flag. + +Timeouts might not be enabled by default. See the documentation for `Wire.setWireTimeout()` for more information on how to configure timeouts and how they work. + + +[float] +=== Syntax + +`Wire.clearTimeout()` + +[float] +=== Parameters +None. + +[float] +=== Returns +* bool: The current value of the flag + +[float] +=== Portability Notes +This function was not available in the original version of the Wire library and might still not be available on all platforms. Code that needs to be portable across platforms and versions can use the `WIRE_HAS_TIMEOUT` macro, which is only defined when `Wire.setWireTimeout()`, `Wire.getWireTimeoutFlag()` and `Wire.clearWireTimeout()` are all available. + +-- + +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/end.adoc b/Language/Functions/Communication/Wire/end.adoc new file mode 100644 index 000000000..74871fba4 --- /dev/null +++ b/Language/Functions/Communication/Wire/end.adoc @@ -0,0 +1,31 @@ +--- +title: end() +--- += end + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + +Disable the Wire library, reversing the effect of `Wire.begin()`. To use the Wire library again after this, call `Wire.begin()` again. + +*Note:* This function was not available in the original version of the Wire library and might still not be available on all platforms. Code that needs to be portable across platforms and versions can use the `WIRE_HAS_END` macro, which is only defined when `Wire.end()` is available. + +[float] +=== Syntax + +`Wire.end()` + +[float] +=== Parameters +None. + +[float] +=== Returns +None. +-- + +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/endTransmission.adoc b/Language/Functions/Communication/Wire/endTransmission.adoc new file mode 100644 index 000000000..94efab0c1 --- /dev/null +++ b/Language/Functions/Communication/Wire/endTransmission.adoc @@ -0,0 +1,34 @@ +--- +title: endTransmission() +--- + += endTransmission + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function ends a transmission to a peripheral device that was begun by `beginTransmission()` and transmits the bytes that were queued by `write()`. As of Arduino 1.0.1, `endTransmission()` accepts a boolean argument changing its behavior for compatibility with certain I2C devices. If true, `endTransmission()` sends a stop message after transmission, releasing the I2C bus. If false, `endTransmission()` sends a restart message after transmission. The bus will not be released, which prevents another controller device from transmitting between messages. This allows one controller device to send multiple transmissions while in control. The default value is true. + +[float] +=== Syntaxx +`Wire.endTransmission()` +`Wire.endTransmission(stop)` + +[float] +=== Parameterss + +* _stop_: true or false. True will send a stop message, releasing the bus after transmission. False will send a restart, keeping the connection active. +[float] +=== Returns + +* _0_: success. +* _1_: data too long to fit in transmit buffer. +* _2_: received NACK on transmit of address. +* _3_: received NACK on transmit of data. +* _4_: other error. +* _5_: timeout +-- +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/getWireTimeoutFlag.adoc b/Language/Functions/Communication/Wire/getWireTimeoutFlag.adoc new file mode 100644 index 000000000..25c5301d2 --- /dev/null +++ b/Language/Functions/Communication/Wire/getWireTimeoutFlag.adoc @@ -0,0 +1,37 @@ +--- +title: getWireTimeoutFlag() +--- += getWireTimeoutFlag + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + +Checks whether a timeout has occured since the last time the flag was cleared. + +This flag is set is set whenever a timeout occurs and cleared when `Wire.clearWireTimeoutFlag()` is called, or when the timeout is changed using `Wire.setWireTimeout()`. + + +[float] +=== Syntax + +`Wire.getWireTimeoutFlag()` + +[float] +=== Parameters +None. + +[float] +=== Returns +* bool: The current value of the flag + +[float] +=== Portability Notes +This function was not available in the original version of the Wire library and might still not be available on all platforms. Code that needs to be portable across platforms and versions can use the `WIRE_HAS_TIMEOUT` macro, which is only defined when `Wire.setWireTimeout()`, `Wire.getWireTimeoutFlag()` and `Wire.clearWireTimeout()` are all available. + +-- + +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/onReceive.adoc b/Language/Functions/Communication/Wire/onReceive.adoc new file mode 100644 index 000000000..7b102215d --- /dev/null +++ b/Language/Functions/Communication/Wire/onReceive.adoc @@ -0,0 +1,30 @@ +--- +title: onReceieve() +--- + += onReceive + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + +This function registers a function to be called when a peripheral device receives a transmission from a controller device. + +[float] +=== Syntax +`Wire.onReceive(handler)` + +[float] +=== Parameters + +* _handler_: the function to be called when the peripheral device receives data; this should take a single int parameter (the number of bytes read from the controller device) and return nothing. + +[float] +=== Returns + +None. +-- +//OVERVIEW SECTION ENDS diff --git a/Language/Functions/Communication/Wire/onRequest.adoc b/Language/Functions/Communication/Wire/onRequest.adoc new file mode 100644 index 000000000..3b56c9a8d --- /dev/null +++ b/Language/Functions/Communication/Wire/onRequest.adoc @@ -0,0 +1,30 @@ +--- +title: onRequest() +--- + += onRequest + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function registers a function to be called when a controller device requests data from a peripheral device. + +[float] +=== Syntax +`Wire.onRequest(handler)` + +[float] +=== Parameters + +* _handler_: the function to be called, takes no parameters and returns nothing. + +[float] +=== Returns + +None. + +-- +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/read.adoc b/Language/Functions/Communication/Wire/read.adoc new file mode 100644 index 000000000..73f56240f --- /dev/null +++ b/Language/Functions/Communication/Wire/read.adoc @@ -0,0 +1,54 @@ +--- +title: read() +--- + += read + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function reads a byte that was transmitted from a peripheral device to a controller device after a call to `requestFrom()` or was transmitted from a controller device to a peripheral device. `read()` inherits from the Stream utility class. + +[float] +=== Syntax +`Wire.read()` + +[float] +=== Parameters + +None. + +[float] +=== Returns + +The next byte received. + +[float] +=== Example + +``` +#include + +void setup() { + Wire.begin(); // Join I2C bus (address is optional for controller device) + Serial.begin(9600); // Start serial for output +} + +void loop() { + Wire.requestFrom(2, 6); // Request 6 bytes from slave device number two + + // Slave may send less than requested + while(Wire.available()) { + char c = Wire.read(); // Receive a byte as character + Serial.print(c); // Print the character + } + + delay(500); +} +``` + +-- +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/requestFrom.adoc b/Language/Functions/Communication/Wire/requestFrom.adoc new file mode 100644 index 000000000..ca9f2a441 --- /dev/null +++ b/Language/Functions/Communication/Wire/requestFrom.adoc @@ -0,0 +1,33 @@ +--- +title: requestFrom() +--- + += requestFrom + +// OVERVIEW SECTION STARTS +[#overview] + +-- + +[float] +=== Description +This function is used by the controller device to request bytes from a peripheral device. The bytes may then be retrieved with the `available()` and `read()` functions. As of Arduino 1.0.1, `requestFrom()` accepts a boolean argument changing its behavior for compatibility with certain I2C devices. If true, `requestFrom()` sends a stop message after the request, releasing the I2C bus. If false, `requestFrom()` sends a restart message after the request. The bus will not be released, which prevents another master device from requesting between messages. This allows one master device to send multiple requests while in control. The default value is true. + +[float] +=== Syntax +`Wire.requestFrom(address, quantity)` + +`Wire.requestFrom(address, quantity, stop)` + +[float] +=== Parameters +* _address_: the 7-bit slave address of the device to request bytes from. +* _quantity_: the number of bytes to request. +* _stop_: true or false. true will send a stop message after the request, releasing the bus. False will continually send a restart after the request, keeping the connection active. + +[float] +=== Returns +* _byte_ : the number of bytes returned from the peripheral device. + +-- +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/setClock.adoc b/Language/Functions/Communication/Wire/setClock.adoc new file mode 100644 index 000000000..f47de0c20 --- /dev/null +++ b/Language/Functions/Communication/Wire/setClock.adoc @@ -0,0 +1,28 @@ +--- +title: setClock() +--- + += setClock + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function modifies the clock frequency for I2C communication. I2C peripheral devices have no minimum working clock frequency, however 100KHz is usually the baseline. + +[float] +=== Syntax +`Wire.setClock(clockFrequency)` + +[float] +=== Parameters +* _clockFrequency_: the value (in Hertz) of the desired communication clock. Accepted values are 100000 (standard mode) and 400000 (fast mode). Some processors also support 10000 (low speed mode), 1000000 (fast mode plus) and 3400000 (high speed mode). Please refer to the specific processor documentation to make sure the desired mode is supported. + +[float] +=== Returns + +None. +-- +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/setWireTimeout.adoc b/Language/Functions/Communication/Wire/setWireTimeout.adoc new file mode 100644 index 000000000..761e6797c --- /dev/null +++ b/Language/Functions/Communication/Wire/setWireTimeout.adoc @@ -0,0 +1,105 @@ +--- +title: setWireTimeout() +--- += setWireTimeout + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description + +Sets the timeout for Wire transmissions in master mode. + +*Note:* these timeouts are almost always an indication of an underlying problem, such as misbehaving devices, noise, insufficient shielding, or other electrical problems. These timeouts will prevent your sketch from locking up, but not solve these problems. In such situations there will often (also) be data corruption which doesn't result in a timeout or other error and remains undetected. So when a timeout happens, it is likely that some data previously read or written is also corrupted. Additional measures might be needed to more reliably detect such issues (e.g. checksums or reading back written values) and recover from them (e.g. full system reset). This timeout and such additional measures should be seen as a last line of defence, when possible the underlying cause should be fixed instead. + +[float] +=== Syntax + +`Wire.setWireTimeout(timeout, reset_on_timeout)` + +`Wire.setWireTimeout()` + +[float] +=== Parameters +* `timeout a timeout`: timeout in microseconds, if zero then timeout checking is disabled +* `reset_on_timeout`: if true then Wire hardware will be automatically reset on timeout + +When this function is called without parameters, a default timeout is configured that should be sufficient to prevent lockups in a typical single-master configuration. + +[float] +=== Returns +None. + +[float] +=== Example Code + +``` +#include + +void setup() { + Wire.begin(); // join i2c bus (address optional for master) + #if defined(WIRE_HAS_TIMEOUT) + Wire.setWireTimeout(3000 /* us */, true /* reset_on_timeout */); + #endif +} + +byte x = 0; + +void loop() { + /* First, send a command to the other device */ + Wire.beginTransmission(8); // transmit to device #8 + Wire.write(123); // send command + byte error = Wire.endTransmission(); // run transaction + if (error) { + Serial.println("Error occured when writing"); + if (error == 5) + Serial.println("It was a timeout"); + } + + delay(100); + + /* Then, read the result */ + #if defined(WIRE_HAS_TIMEOUT) + Wire.clearWireTimeoutFlag(); + #endif + byte len = Wire.requestFrom(8, 1); // request 1 byte from device #8 + if (len == 0) { + Serial.println("Error occured when reading"); + #if defined(WIRE_HAS_TIMEOUT) + if (Wire.getWireTimeoutFlag()) + Serial.println("It was a timeout"); + #endif + } + + delay(100); +} +``` + +[float] +=== Notes and Warnings + +How this timeout is implemented might vary between different platforms, but typically a timeout condition is triggered when waiting for (some part of) the transaction to complete (e.g. waiting for the bus to become available again, waiting for an ACK bit, or maybe waiting for the entire transaction to be completed). + +When such a timeout condition occurs, the transaction is aborted and `endTransmission()` or `requestFrom()` will return an error code or zero bytes respectively. While this will not resolve the bus problem by itself (i.e. it does not remove a short-circuit), it will at least prevent blocking potentially indefinitely and allow your software to detect and maybe solve this condition. + +If `reset_on_timeout` was set to true and the platform supports this, the Wire hardware is also reset, which can help to clear any incorrect state inside the Wire hardware module. For example, on the AVR platform, this can be required to restart communications after a noise-induced timeout. + +When a timeout is triggered, a flag is set that can be queried with `getWireTimeoutFlag()` and must be cleared manually using `clearWireTimeoutFlag()` (and is also cleared when `setWireTimeout()` is called). + +Note that this timeout can also trigger while waiting for clock stretching or waiting for a second master to complete its transaction. So make sure to adapt the timeout to accomodate for those cases if needed. A typical timeout would be 25ms (which is the maximum clock stretching allowed by the SMBus protocol), but (much) shorter values will usually also work. + + +[float] +=== Portability Notes + +This function was not available in the original version of the Wire library and might still not be available on all platforms. Code that needs to be portable across platforms and versions can use the `WIRE_HAS_TIMEOUT` macro, which is only defined when `Wire.setWireTimeout()`, `Wire.getWireTimeoutFlag()` and `Wire.clearWireTimeout()` are all available. + +When this timeout feature was introduced on the AVR platform, it was initially kept disabled by default for compatibility, expecting it to become enabled at a later point. This means the default value of the timeout can vary between (versions of) platforms. The default timeout settings are available from the `WIRE_DEFAULT_TIMEOUT` and `WIRE_DEFAULT_RESET_WITH_TIMEOUT` macro. + +If you require the timeout to be disabled, it is recommended you disable it by default using `setWireTimeout(0)`, even though that is currently the default. + +-- + +//OVERVIEW SECTION ENDS \ No newline at end of file diff --git a/Language/Functions/Communication/Wire/write.adoc b/Language/Functions/Communication/Wire/write.adoc new file mode 100644 index 000000000..3bd29962d --- /dev/null +++ b/Language/Functions/Communication/Wire/write.adoc @@ -0,0 +1,61 @@ +--- +title: write() +--- + += write + +//OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +This function writes data from a peripheral device in response to a request from a controller device, or queues bytes for transmission from a controller to peripheral device (in-between calls to `beginTransmission()` and `endTransmission()`). + +[float] +=== Syntax +`Wire.write(value)` +`Wire.write(string)` +`Wire.write(data, length)` + +[float] +=== Parameters +* _value_: a value to send as a single byte. +* _string_: a string to send as a series of bytes. +* _data_: an array of data to send as bytes. +* _length_: the number of bytes to transmit. + +[float] +=== Returns + +The number of bytes written (reading this number is optional). +[float] +=== Example + +``` +#include + +byte val = 0; + +void setup() { + Wire.begin(); // Join I2C bus +} + +void loop() { + Wire.beginTransmission(44); // Transmit to device number 44 (0x2C) + + Wire.write(val); // Sends value byte + Wire.endTransmission(); // Stop transmitting + + val++; // Increment value + + // if reached 64th position (max) + if(val == 64) { + val = 0; // Start over from lowest value + } + + delay(500); +} +``` +-- +//OVERVIEW SECTION ENDS From 6291a271e3f1ae42a40bbc1859bfded3c39aa88a Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sat, 19 Mar 2022 22:44:38 +0100 Subject: [PATCH 075/184] keyboardModifiers: split modifiers and special keys Language/Functions/USB/Keyboard/keyboardModifiers.adoc contains a table of key macros described as "modifier keys". Most entries in this table, however, are not modifiers: arrow keys, function keys, etc. Split the table in two: one table for the actual modifiers, and another one for all the other key macros, collectively described as "special keys". --- .../USB/Keyboard/keyboardModifiers.adoc | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc index 6ff0b9c75..55dabfbe9 100644 --- a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc +++ b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc @@ -1,11 +1,11 @@ --- -title: Keyboard Modifiers +title: Keyboard Modifiers and Special Keys --- -= Keyboard Modifiers += Keyboard modifiers and special keys // OVERVIEW SECTION STARTS @@ -16,9 +16,11 @@ title: Keyboard Modifiers === Description The `Keyboard.write()` and `Keyboard.press()` and `Keyboard.release()` commands don’t work with every possible ASCII character, only those that correspond to a key on the keyboard. For example, backspace works, but many of the other non-printable characters produce unpredictable results. For capital letters (and other keys), what’s sent is shift plus the character (i.e. the equivalent of pressing both of those keys on the keyboard). [%hardbreaks] -A modifier key is a special key on a computer keyboard that modifies the normal action of another key when the two are pressed in combination. -[%hardbreaks] For more on ASCII values and the characters or functions they represent, see http://www.asciitable.com/[asciitable.com] + +[float] +=== Keyboard modifiers +A modifier key is a special key on a computer keyboard that modifies the normal action of another key when the two are pressed in combination. [%hardbreaks] For multiple key presses use link:../keyboardpress[Keyboard.press]() [%hardbreaks] @@ -37,6 +39,17 @@ The definitions of the modifier keys are listed below: |KEY_RIGHT_SHIFT |0x85 |133 |KEY_RIGHT_ALT |0x86 |134 |KEY_RIGHT_GUI |0x87 |135 +|=== + +[float] +=== Special keys +These are four keys within the alphanumeric cluster of a keyboard (Tab, Caps Lock, Backspace and Return) as well as all keys from outside that cluster (Escape, function keys, Home, End, arrow keys...). + +The following special keys have been defined: + +|=== +|Key |Hexadecimal value |Decimal value + |KEY_UP_ARROW |0xDA |218 |KEY_DOWN_ARROW |0xD9 |217 |KEY_LEFT_ARROW |0xD8 |216 From ed21ef0a041c9b69850c0fe54d08e7b6596e602d Mon Sep 17 00:00:00 2001 From: Takahiro FUJIWARA Date: Sat, 26 Mar 2022 20:33:39 +0100 Subject: [PATCH 076/184] update print.doc -- In case of floating-point and specify the number of decimal places, Serial.print() supports rounding. 0 to 4 then rounddown, 5 to 9 then round up. so the original text Serial.print(1.23456, 4) gives "1.2345" should be: Serial.print(1.23456, 4) gives "1.2346" I checked the result on TINKERCAD and update line is correct. --- Language/Functions/Communication/Serial/print.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Serial/print.adoc b/Language/Functions/Communication/Serial/print.adoc index ff3cbe14a..eb2d5732f 100644 --- a/Language/Functions/Communication/Serial/print.adoc +++ b/Language/Functions/Communication/Serial/print.adoc @@ -30,7 +30,7 @@ An optional second parameter specifies the base (format) to use; permitted value * `_Serial_.print(78, HEX)` gives "4E" + * `_Serial_.print(1.23456, 0)` gives "1" + * `_Serial_.print(1.23456, 2)` gives "1.23" + -* `_Serial_.print(1.23456, 4)` gives "1.2345" +* `_Serial_.print(1.23456, 4)` gives "1.2346" You can pass flash-memory based strings to `_Serial_.print()` by wrapping them with link:../../../../variables/utilities/progmem[F()]. For example: From 5af83af0450ec1c14c135054cf69df5939c482ca Mon Sep 17 00:00:00 2001 From: Matt Borja <3855027+mattborja@users.noreply.github.com> Date: Wed, 13 Apr 2022 01:14:01 -0700 Subject: [PATCH 077/184] Fix misspellings in headings Headings: - "Syntax" - "Parameters" --- Language/Functions/Communication/Wire/endTransmission.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Language/Functions/Communication/Wire/endTransmission.adoc b/Language/Functions/Communication/Wire/endTransmission.adoc index 94efab0c1..2040ca993 100644 --- a/Language/Functions/Communication/Wire/endTransmission.adoc +++ b/Language/Functions/Communication/Wire/endTransmission.adoc @@ -13,12 +13,12 @@ title: endTransmission() This function ends a transmission to a peripheral device that was begun by `beginTransmission()` and transmits the bytes that were queued by `write()`. As of Arduino 1.0.1, `endTransmission()` accepts a boolean argument changing its behavior for compatibility with certain I2C devices. If true, `endTransmission()` sends a stop message after transmission, releasing the I2C bus. If false, `endTransmission()` sends a restart message after transmission. The bus will not be released, which prevents another controller device from transmitting between messages. This allows one controller device to send multiple transmissions while in control. The default value is true. [float] -=== Syntaxx +=== Syntax `Wire.endTransmission()` `Wire.endTransmission(stop)` [float] -=== Parameterss +=== Parameters * _stop_: true or false. True will send a stop message, releasing the bus after transmission. False will send a restart, keeping the connection active. [float] @@ -31,4 +31,4 @@ This function ends a transmission to a peripheral device that was begun by `begi * _4_: other error. * _5_: timeout -- -//OVERVIEW SECTION ENDS \ No newline at end of file +//OVERVIEW SECTION ENDS From 1b6b2cb898f049d65c4760c872417216a4894076 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Wed, 20 Apr 2022 14:48:30 +0200 Subject: [PATCH 078/184] keyboardModifiers: rewrite the introductory text The main purpose of the page Language/Functions/USB/Keyboard/keyboardModifiers.adoc is to list the macros representing keys. Refocus the text accordingly. --- .../USB/Keyboard/keyboardModifiers.adoc | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc index 55dabfbe9..8d0053633 100644 --- a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc +++ b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc @@ -14,19 +14,26 @@ title: Keyboard Modifiers and Special Keys [float] === Description -The `Keyboard.write()` and `Keyboard.press()` and `Keyboard.release()` commands don’t work with every possible ASCII character, only those that correspond to a key on the keyboard. For example, backspace works, but many of the other non-printable characters produce unpredictable results. For capital letters (and other keys), what’s sent is shift plus the character (i.e. the equivalent of pressing both of those keys on the keyboard). +When given a printable ASCII character as an argument, the functions `Keyboard.write()`, `Keyboard.press()` and `Keyboard.release()` simulate actuations on the corresponding keys. These functions can also handle ASCII characters that require pressing a key in combination with Shift or, on international keyboards, AltGr. For example: +[source,arduino] +---- +Keyboard.write('a'); // press and release the 'A' key +Keyboard.write('A'); // press Shift and 'A', then release both +---- +A typical keyboard, however, has many keys that do not match a printable ASCII character. In order to simulate those keys, the library provides a set of macros that can be passed as arguments to `Keyboard.write()`, `Keyboard.press()` and `Keyboard.release()`. For example, the key combination Shift-F2 can be generated by: +[source,arduino] +---- +Keyboard.press(KEY_LEFT_SHIFT); // press and hold Shift +Keyboard.press(KEY_F2); // press and hold F2 +Keyboard.releaseAll(); // release both +---- +Note that, in order to press multiple keys simultaneously, one has to use link:../keyboardpress[`Keyboard.press()`] rather than link:../keyboardwrite[`Keyboard.write()`], as the latter just “hits” the keys (it presses and immediate releases them). [%hardbreaks] -For more on ASCII values and the characters or functions they represent, see http://www.asciitable.com/[asciitable.com] +The available macros are listed below: [float] === Keyboard modifiers -A modifier key is a special key on a computer keyboard that modifies the normal action of another key when the two are pressed in combination. -[%hardbreaks] -For multiple key presses use link:../keyboardpress[Keyboard.press]() -[%hardbreaks] -The definitions of the modifier keys are listed below: -[%hardbreaks] - +These are eight keys within the alphanumeric cluster of the keyboard that are meant to modify the normal action of another key when the two are pressed in combination. Whereas Shift and AltGr are used to access extra characters, the others are mostly used for keyboard shortcuts. |=== |Key |Hexadecimal value |Decimal value @@ -43,9 +50,7 @@ The definitions of the modifier keys are listed below: [float] === Special keys -These are four keys within the alphanumeric cluster of a keyboard (Tab, Caps Lock, Backspace and Return) as well as all keys from outside that cluster (Escape, function keys, Home, End, arrow keys...). - -The following special keys have been defined: +These are all the keys that do not match a printable ASCII character and are not modifiers, including all keys outside the alphanumeric cluster. |=== |Key |Hexadecimal value |Decimal value From 42081fa836411589b5748d6fdf00396b493a6331 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sat, 2 Apr 2022 18:23:45 +0200 Subject: [PATCH 079/184] keyboardModifiers: split keys into smaller groups Language/Functions/USB/Keyboard/keyboardModifiers.adoc contains a long list of macros corresponding to keys. Make this list easier to parse by organizing the keys into meaningful groups. --- .../USB/Keyboard/keyboardModifiers.adoc | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc index 8d0053633..42f0b1a95 100644 --- a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc +++ b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc @@ -52,24 +52,44 @@ These are eight keys within the alphanumeric cluster of the keyboard that are me === Special keys These are all the keys that do not match a printable ASCII character and are not modifiers, including all keys outside the alphanumeric cluster. +[float] +==== Within the alphanumeric cluster + |=== |Key |Hexadecimal value |Decimal value -|KEY_UP_ARROW |0xDA |218 -|KEY_DOWN_ARROW |0xD9 |217 -|KEY_LEFT_ARROW |0xD8 |216 -|KEY_RIGHT_ARROW |0xD7 |215 -|KEY_BACKSPACE |0xB2 |178 |KEY_TAB |0xB3 |179 +|KEY_CAPS_LOCK |0xC1 |193 +|KEY_BACKSPACE |0xB2 |178 |KEY_RETURN |0xB0 |176 -|KEY_ESC |0xB1 |177 +|=== + +[float] +==== Navigation cluster + +|=== +|Key |Hexadecimal value |Decimal value + |KEY_INSERT |0xD1 |209 |KEY_DELETE |0xD4 |212 -|KEY_PAGE_UP |0xD3 |211 -|KEY_PAGE_DOWN |0xD6 |214 |KEY_HOME |0xD2 |210 |KEY_END |0xD5 |213 -|KEY_CAPS_LOCK |0xC1 |193 +|KEY_PAGE_UP |0xD3 |211 +|KEY_PAGE_DOWN |0xD6 |214 +|KEY_UP_ARROW |0xDA |218 +|KEY_DOWN_ARROW |0xD9 |217 +|KEY_LEFT_ARROW |0xD8 |216 +|KEY_RIGHT_ARROW |0xD7 |215 +|=== + +[float] +==== Escape and function keys +The library can simulate function keys up to F24, even though few keyboards have the F13… F24 keys. + +|=== +|Key |Hexadecimal value |Decimal value + +|KEY_ESC |0xB1 |177 |KEY_F1 |0xC2 |194 |KEY_F2 |0xC3 |195 |KEY_F3 |0xC4 |196 From a7b4ff990af68a2007842c50f933c8cb3d1eaf43 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sat, 2 Apr 2022 20:34:54 +0200 Subject: [PATCH 080/184] keyboardModifiers: add notes to ambiguous keys In Language/Functions/USB/Keyboard/keyboardModifiers.adoc, add explanatory notes for keys with ambiguous names: - KEY_{LEFT,RIGHT}_GUI are the OS logo keys, "command" on Mac - KEY_{LEFT,RIGHT}_ALT is "option" on Mac - KEY_RIGHT_ALT can be labeled "AltGr". --- .../USB/Keyboard/keyboardModifiers.adoc | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc index 42f0b1a95..30e85b935 100644 --- a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc +++ b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc @@ -36,16 +36,16 @@ The available macros are listed below: These are eight keys within the alphanumeric cluster of the keyboard that are meant to modify the normal action of another key when the two are pressed in combination. Whereas Shift and AltGr are used to access extra characters, the others are mostly used for keyboard shortcuts. |=== -|Key |Hexadecimal value |Decimal value - -|KEY_LEFT_CTRL |0x80 |128 -|KEY_LEFT_SHIFT |0x81 |129 -|KEY_LEFT_ALT |0x82 |130 -|KEY_LEFT_GUI |0x83 |131 -|KEY_RIGHT_CTRL |0x84 |132 -|KEY_RIGHT_SHIFT |0x85 |133 -|KEY_RIGHT_ALT |0x86 |134 -|KEY_RIGHT_GUI |0x87 |135 +|Key |Hexadecimal value |Decimal value |Notes + +|KEY_LEFT_CTRL |0x80 |128 | +|KEY_LEFT_SHIFT |0x81 |129 | +|KEY_LEFT_ALT |0x82 |130 |option (⌥) on Mac +|KEY_LEFT_GUI |0x83 |131 |OS logo, command (⌘) on Mac +|KEY_RIGHT_CTRL |0x84 |132 | +|KEY_RIGHT_SHIFT |0x85 |133 | +|KEY_RIGHT_ALT |0x86 |134 |also AltGr, option (⌥) on Mac +|KEY_RIGHT_GUI |0x87 |135 |OS logo, command (⌘) on Mac |=== [float] From 0a0c5b4bfc3f1aca0cbd85d52b91ea03e0a9106c Mon Sep 17 00:00:00 2001 From: Siesta <90094025+Pbaodoge@users.noreply.github.com> Date: Sun, 24 Apr 2022 08:15:43 +0700 Subject: [PATCH 081/184] Fixed grammar mistake --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index cbe8fde78..90010049d 100644 --- a/README.adoc +++ b/README.adoc @@ -47,7 +47,7 @@ reference-en │ ├── Functions │ ├── Structure │ └── Variables -├── LICENCE.md +├── LICENSE.md └── README.adoc ---- From eba85e412125418ec3d480ff24edbed292666888 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sat, 7 May 2022 14:31:32 +0200 Subject: [PATCH 082/184] keyboardModifiers: Implement review suggestions Apply changes suggested by @per1234 on pull-request review: - fix typo - use common conventions for key names and key combinations - reduce unnecessary verbosity. Co-authored-by: per1234 --- .../USB/Keyboard/keyboardModifiers.adoc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc index 30e85b935..f6b86b558 100644 --- a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc +++ b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc @@ -20,37 +20,37 @@ When given a printable ASCII character as an argument, the functions `Keyboard.w Keyboard.write('a'); // press and release the 'A' key Keyboard.write('A'); // press Shift and 'A', then release both ---- -A typical keyboard, however, has many keys that do not match a printable ASCII character. In order to simulate those keys, the library provides a set of macros that can be passed as arguments to `Keyboard.write()`, `Keyboard.press()` and `Keyboard.release()`. For example, the key combination Shift-F2 can be generated by: +A typical keyboard, however, has many keys that do not match a printable ASCII character. In order to simulate those keys, the library provides a set of macros that can be passed as arguments to `Keyboard.write()`, `Keyboard.press()` and `Keyboard.release()`. For example, the key combination Shift+F2 can be generated by: [source,arduino] ---- Keyboard.press(KEY_LEFT_SHIFT); // press and hold Shift Keyboard.press(KEY_F2); // press and hold F2 Keyboard.releaseAll(); // release both ---- -Note that, in order to press multiple keys simultaneously, one has to use link:../keyboardpress[`Keyboard.press()`] rather than link:../keyboardwrite[`Keyboard.write()`], as the latter just “hits” the keys (it presses and immediate releases them). +Note that, in order to press multiple keys simultaneously, one has to use link:../keyboardpress[`Keyboard.press()`] rather than link:../keyboardwrite[`Keyboard.write()`], as the latter just “hits” the keys (it presses and immediately releases them). [%hardbreaks] The available macros are listed below: [float] === Keyboard modifiers -These are eight keys within the alphanumeric cluster of the keyboard that are meant to modify the normal action of another key when the two are pressed in combination. Whereas Shift and AltGr are used to access extra characters, the others are mostly used for keyboard shortcuts. +These keys are meant to modify the normal action of another key when the two are pressed in combination. |=== |Key |Hexadecimal value |Decimal value |Notes |KEY_LEFT_CTRL |0x80 |128 | |KEY_LEFT_SHIFT |0x81 |129 | -|KEY_LEFT_ALT |0x82 |130 |option (⌥) on Mac -|KEY_LEFT_GUI |0x83 |131 |OS logo, command (⌘) on Mac +|KEY_LEFT_ALT |0x82 |130 |Option (⌥) on Mac +|KEY_LEFT_GUI |0x83 |131 |OS logo, Command (⌘) on Mac |KEY_RIGHT_CTRL |0x84 |132 | |KEY_RIGHT_SHIFT |0x85 |133 | -|KEY_RIGHT_ALT |0x86 |134 |also AltGr, option (⌥) on Mac -|KEY_RIGHT_GUI |0x87 |135 |OS logo, command (⌘) on Mac +|KEY_RIGHT_ALT |0x86 |134 |also AltGr, Option (⌥) on Mac +|KEY_RIGHT_GUI |0x87 |135 |OS logo, Command (⌘) on Mac |=== [float] === Special keys -These are all the keys that do not match a printable ASCII character and are not modifiers, including all keys outside the alphanumeric cluster. +These are all the keys that do not match a printable ASCII character and are not modifiers. [float] ==== Within the alphanumeric cluster @@ -84,7 +84,7 @@ These are all the keys that do not match a printable ASCII character and are not [float] ==== Escape and function keys -The library can simulate function keys up to F24, even though few keyboards have the F13… F24 keys. +The library can simulate function keys up to F24. |=== |Key |Hexadecimal value |Decimal value From 33e17beba9825ea31d8c1a0bdcfd5c5a2ae9fb0e Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sat, 7 May 2022 21:57:38 +0200 Subject: [PATCH 083/184] Keyboard.begin(): add Danish and Swedish layouts Version 1.0.4 of the Keyboard library added the Danish and Swedish keyboard layouts. Update the documentation of Keyboard.begin() accordingly. --- Language/Functions/USB/Keyboard/keyboardBegin.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Language/Functions/USB/Keyboard/keyboardBegin.adoc b/Language/Functions/USB/Keyboard/keyboardBegin.adoc index 2c27dbf0f..bdeaab7e7 100644 --- a/Language/Functions/USB/Keyboard/keyboardBegin.adoc +++ b/Language/Functions/USB/Keyboard/keyboardBegin.adoc @@ -33,11 +33,13 @@ When used with a Leonardo or Due board, `Keyboard.begin()` starts emulating a ke === Keyboard layouts Currently, the library supports the following national keyboard layouts: +* `KeyboardLayout_da_DK`: Denmark * `KeyboardLayout_de_DE`: Germany * `KeyboardLayout_en_US`: USA * `KeyboardLayout_es_ES`: Spain * `KeyboardLayout_fr_FR`: France * `KeyboardLayout_it_IT`: Italy +* `KeyboardLayout_sv_SE`: Sweden [float] From daff214c6f675d64a699bd8482030fb88d59b0b0 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sat, 7 May 2022 21:58:06 +0200 Subject: [PATCH 084/184] KeyboardModifiers: add more key macros Version 1.0.4 of the Keyboard library added macros for more special keys, completing the coverage of a full-size PC keyboard. Some language-specific layouts also added their own macros for keys matching non-ASCII characters. Update KeyboardModifiers.adoc accordingly. --- .../USB/Keyboard/keyboardModifiers.adoc | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc index f6b86b558..068bd5e05 100644 --- a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc +++ b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc @@ -62,6 +62,7 @@ These are all the keys that do not match a printable ASCII character and are not |KEY_CAPS_LOCK |0xC1 |193 |KEY_BACKSPACE |0xB2 |178 |KEY_RETURN |0xB0 |176 +|KEY_MENU |0xED |237 |=== [float] @@ -82,6 +83,31 @@ These are all the keys that do not match a printable ASCII character and are not |KEY_RIGHT_ARROW |0xD7 |215 |=== +[float] +==== Numeric keypad + +|=== +|Key |Hexadecimal value |Decimal value + +|KEY_NUM_LOCK |0xDB |219 +|KEY_KP_SLASH |0xDC |220 +|KEY_KP_ASTERISK |0xDD |221 +|KEY_KP_MINUS |0xDE |222 +|KEY_KP_PLUS |0xDF |223 +|KEY_KP_ENTER |0xE0 |224 +|KEY_KP_1 |0xE1 |225 +|KEY_KP_2 |0xE2 |226 +|KEY_KP_3 |0xE3 |227 +|KEY_KP_4 |0xE4 |228 +|KEY_KP_5 |0xE5 |229 +|KEY_KP_6 |0xE6 |230 +|KEY_KP_7 |0xE7 |231 +|KEY_KP_8 |0xE8 |232 +|KEY_KP_9 |0xE9 |233 +|KEY_KP_0 |0xEA |234 +|KEY_KP_DOT |0xEB |235 +|=== + [float] ==== Escape and function keys The library can simulate function keys up to F24. @@ -116,5 +142,37 @@ The library can simulate function keys up to F24. |KEY_F24 |0xFB |251 |=== +[float] +==== Function control keys +These are three rarely used keys that sit above the navigation cluster. + +|=== +|Key |Hexadecimal value |Decimal value |Notes + +|KEY_PRINT_SCREEN |0xCE |206 |Print Screen or PrtSc / SysRq +|KEY_SCROLL_LOCK |0xCF |207 | +|KEY_PAUSE |0xD0 |208 |Pause / Break +|=== + +[float] +==== International keyboard layouts + +Some national layouts define extra keys. For example, the Swedish and Danish layouts define `KEY_A_RING` as `0xB7`, which is the key to the right of “P”, labeled “Å” on those layouts and “{”/“[” on the US layout. In order to use those definitions, one has to include the proper Keyboard_*.h file. For example: + +[source,arduino] +---- +#include +#include // extra key definitions from Swedish layout + +void setup() { + Keyboard.begin(KeyboardLayout_sv_SE); // use the Swedish layout + Keyboard.write(KEY_A_RING); +} + +void loop() {} // do-nothing loop +---- + +For the list of layout-specific key definitions, see the respective Keyboard_*.h file within the library sources. + -- // OVERVIEW SECTION ENDS From d50b693f4c41da0a243eb0766ec8fab63a38b3d3 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Sun, 8 May 2022 09:53:31 +0200 Subject: [PATCH 085/184] keyboardModifiers: Implement review suggestion Reduce unnecessary verbosity. Co-authored-by: per1234 --- Language/Functions/USB/Keyboard/keyboardModifiers.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc index 068bd5e05..3ecd403df 100644 --- a/Language/Functions/USB/Keyboard/keyboardModifiers.adoc +++ b/Language/Functions/USB/Keyboard/keyboardModifiers.adoc @@ -144,7 +144,7 @@ The library can simulate function keys up to F24. [float] ==== Function control keys -These are three rarely used keys that sit above the navigation cluster. +These are three keys that sit above the navigation cluster. |=== |Key |Hexadecimal value |Decimal value |Notes From 272d3ddda2b1d8828b9bd8a0904f9fef67df86d6 Mon Sep 17 00:00:00 2001 From: Arnold <48472227+Arnold-n@users.noreply.github.com> Date: Sun, 8 May 2022 14:17:24 +0200 Subject: [PATCH 086/184] Update Language/Functions/Time/millis.adoc Co-authored-by: per1234 --- Language/Functions/Time/millis.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Time/millis.adoc b/Language/Functions/Time/millis.adoc index 10514ad67..4dc89865c 100644 --- a/Language/Functions/Time/millis.adoc +++ b/Language/Functions/Time/millis.adoc @@ -66,7 +66,7 @@ void loop() { === Notes and Warnings Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. -On some architectures reconfiguration of timers may result in inaccurate millis() readings. AVR-based architectures program a timer to implement millis(): ArduinoCore-AVR programs TIM0 to generate an interrupt every 16384 clock cycles (clock divider set to 64, overflow every 256 ticks). The same holds for ArduinoCore-mega-AVR, except that it uses TIMx if MILLIS_USER_TIMx (0<=x<=3) is defined. The ArduinoCore-SAM(D) architectures program the Systick timer to generate an interrupt every 1 ms. +Reconfiguration of the microcontroller's timers may result in inaccurate `millis()` readings. The "Arduino AVR Boards" and "Arduino megaAVR Boards" cores use Timer0 to generate `millis()`. The "Arduino ARM (32-bits) Boards" and "Arduino SAMD (32-bits ARM Cortex-M0+) Boards" cores use the SysTick timer. -- // HOW TO USE SECTION ENDS From a7fe5efa3b4454b40ccbfd690fe26b04f8f4bf5d Mon Sep 17 00:00:00 2001 From: redfast00 <10746993+redfast00@users.noreply.github.com> Date: Sun, 8 May 2022 15:06:45 +0200 Subject: [PATCH 087/184] Add note that seed should be non-zero (#867) * Add note that seed should be non-zero After losing about a half hour debugging why my code wasn't deterministic when it should be, I found out that `randomSeed` doesn't do anything when the `seed` is zero (https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/WMath.cpp#L30) * Move warning to new notes and warnings section --- Language/Functions/Random Numbers/randomSeed.adoc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Random Numbers/randomSeed.adoc b/Language/Functions/Random Numbers/randomSeed.adoc index 6e9292223..13ee2ad5e 100644 --- a/Language/Functions/Random Numbers/randomSeed.adoc +++ b/Language/Functions/Random Numbers/randomSeed.adoc @@ -32,7 +32,7 @@ Conversely, it can occasionally be useful to use pseudo-random sequences that re [float] === Parameters -`seed`: number to initialize the pseudo-random sequence. Allowed data types: `unsigned long`. +`seed`: non-zero number to initialize the pseudo-random sequence. Allowed data types: `unsigned long`. [float] @@ -69,6 +69,11 @@ void loop() { delay(50); } ---- +[%hardbreaks] + +[float] +=== Notes and Warnings +If the `seed` is 0, `randomSeed(seed)` will have no effect. -- // HOW TO USE SECTION ENDS From 020b3a22b1a31cbba12dfc030b9361685934d877 Mon Sep 17 00:00:00 2001 From: Andrew Koroluk Date: Mon, 9 May 2022 14:28:55 -0400 Subject: [PATCH 088/184] Update flush.adoc (#777) * Update flush.adoc * Update Language/Functions/Communication/Serial/flush.adoc Co-authored-by: per1234 Co-authored-by: per1234 --- Language/Functions/Communication/Serial/flush.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Serial/flush.adoc b/Language/Functions/Communication/Serial/flush.adoc index c3c6f43b8..b4cdcac72 100644 --- a/Language/Functions/Communication/Serial/flush.adoc +++ b/Language/Functions/Communication/Serial/flush.adoc @@ -16,7 +16,7 @@ title: Serial.flush() === Description Waits for the transmission of outgoing serial data to complete. (Prior to Arduino 1.0, this instead removed any buffered incoming serial data.) -`flush()` inherits from the link:../flush[Stream] utility class. +`flush()` inherits from the link:../../stream/streamflush[Stream] utility class. [%hardbreaks] From 9866b8a3a62909f4ce6784e8f388af8b2b8c84ec Mon Sep 17 00:00:00 2001 From: rohoog <33842942+rohoog@users.noreply.github.com> Date: Wed, 18 May 2022 22:15:13 +0200 Subject: [PATCH 089/184] Move the remark to the standard Notes and Warnings section --- Language/Functions/Communication/Serial/ifSerial.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Language/Functions/Communication/Serial/ifSerial.adoc b/Language/Functions/Communication/Serial/ifSerial.adoc index c2988a863..42b3b48d7 100644 --- a/Language/Functions/Communication/Serial/ifSerial.adoc +++ b/Language/Functions/Communication/Serial/ifSerial.adoc @@ -37,10 +37,6 @@ None Returns true if the specified serial port is available. This will only return false if querying the Leonardo's USB CDC serial connection before it is ready. Data type: `bool`. -[float] -=== Warning -This function adds a delay of 10ms in an attempt to solve "open but not quite" situations. Don't use it in tight loops. - -- // OVERVIEW SECTION ENDS @@ -71,5 +67,9 @@ void loop() { } ---- +[float] +=== Notes and Warnings +This function adds a delay of 10ms in an attempt to solve "open but not quite" situations. Don't use it in tight loops. + -- // HOW TO USE SECTION ENDS From ac442c99b8c08b11f050beccf103acdbe58ed949 Mon Sep 17 00:00:00 2001 From: Marco Tedaldi Date: Sun, 5 Jun 2022 08:23:13 +0200 Subject: [PATCH 090/184] Update Language/Functions/Communication/Serial/serialEvent.adoc Co-authored-by: per1234 --- Language/Functions/Communication/Serial/serialEvent.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Serial/serialEvent.adoc b/Language/Functions/Communication/Serial/serialEvent.adoc index 5201017eb..b3260884a 100644 --- a/Language/Functions/Communication/Serial/serialEvent.adoc +++ b/Language/Functions/Communication/Serial/serialEvent.adoc @@ -14,7 +14,7 @@ title: serialEvent() [float] === Description -Called at the end of loop() when data is available. Use `Serial.read()` to capture this data. +Called at the end of link:../../../../structure/sketch/loop[`loop()`] when data is available. Use `Serial.read()` to capture this data. [%hardbreaks] From 0f4e995887ba0f5f7277e5e2a034bde056f1572b Mon Sep 17 00:00:00 2001 From: HowardWParr <107371728+HowardWParr@users.noreply.github.com> Date: Sun, 12 Jun 2022 17:19:35 -0500 Subject: [PATCH 091/184] Update bitSet.adoc Corrected Return results and added Example Code to more closely resemble the information provided in the reciprocal bitClear() function. --- Language/Functions/Bits and Bytes/bitSet.adoc | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Bits and Bytes/bitSet.adoc b/Language/Functions/Bits and Bytes/bitSet.adoc index d5c49a018..4723baf4e 100644 --- a/Language/Functions/Bits and Bytes/bitSet.adoc +++ b/Language/Functions/Bits and Bytes/bitSet.adoc @@ -34,7 +34,26 @@ Sets (writes a 1 to) a bit of a numeric variable. [float] === Returns -Nothing +x: the value of the numeric variable after the bit at position n is cleared. + + +[float] +=== Example Code +Prints the output of bitSet(x,n) on two given integers. The binary representation of 4 is 0100, so when n=1, the second bit from the right is set to 1. After this we are left with 0110 in binary, so 6 is returned. + +void setup() { + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + int x = 4; + int n = 1; + Serial.print(bitSet(x, n)); // print the output of bitSet(x,n) +} + +void loop() { +} -- // OVERVIEW SECTION ENDS @@ -46,6 +65,7 @@ Nothing [float] === See also +bitClear() -- // SEE ALSO SECTION ENDS From 074f4d2f081c9d6f7251b08b990b09709c3c580b Mon Sep 17 00:00:00 2001 From: HowardWParr <107371728+HowardWParr@users.noreply.github.com> Date: Sun, 12 Jun 2022 23:17:34 -0500 Subject: [PATCH 092/184] Update bitSet.adoc Corrected a typo. --- Language/Functions/Bits and Bytes/bitSet.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Bits and Bytes/bitSet.adoc b/Language/Functions/Bits and Bytes/bitSet.adoc index 4723baf4e..828daebf6 100644 --- a/Language/Functions/Bits and Bytes/bitSet.adoc +++ b/Language/Functions/Bits and Bytes/bitSet.adoc @@ -34,7 +34,7 @@ Sets (writes a 1 to) a bit of a numeric variable. [float] === Returns -x: the value of the numeric variable after the bit at position n is cleared. +x: the value of the numeric variable after the bit at position n is set. [float] From eeca98e95936f76ede658dc4c834c4e5b71563ab Mon Sep 17 00:00:00 2001 From: boundmaidlea <106570003+boundmaidlea@users.noreply.github.com> Date: Sun, 19 Jun 2022 05:12:31 +0200 Subject: [PATCH 093/184] Add link to "Else" page Add a link to [structure/control-structure/else](https://www.arduino.cc/reference/en/language/structure/control-structure/else/) to the *See also* section. --- Language/Structure/Control Structure/if.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/Language/Structure/Control Structure/if.adoc b/Language/Structure/Control Structure/if.adoc index f5c300396..45ad2da20 100644 --- a/Language/Structure/Control Structure/if.adoc +++ b/Language/Structure/Control Structure/if.adoc @@ -101,6 +101,7 @@ This is because C++ evaluates the statement `if (x=10)` as follows: 10 is assign === See also [role="language"] +* #LANGUAGE# link:../else[else] -- // SEE ALSO SECTION ENDS From 8838a08286f9715ddb256bda1417284d25a69c78 Mon Sep 17 00:00:00 2001 From: krytie75 <7768438+krytie75@users.noreply.github.com> Date: Mon, 20 Jun 2022 22:20:30 +0100 Subject: [PATCH 094/184] Add missing function (endTransmission()) endTransmission function page exists but link is missing from the function list on the Wire.h page. --- Language/Functions/Communication/Wire.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Wire.adoc b/Language/Functions/Communication/Wire.adoc index 943ba09f3..8607a3e40 100644 --- a/Language/Functions/Communication/Wire.adoc +++ b/Language/Functions/Communication/Wire.adoc @@ -62,6 +62,7 @@ link:../wire/begin[begin()] + link:../wire/end[end()] + link:../wire/requestfrom[requestFrom()] + link:../wire/begintransmission[beginTransmission()] + +link:../wire/endtransmission[endTransmission()] + link:../wire/write[write()] + link:../wire/available[available()] + link:../wire/read[read()] + @@ -75,4 +76,4 @@ link:../wire/getwiretimeoutflag[getWireTimeoutFlag()] ''' -- -// FUNCTION SECTION ENDS \ No newline at end of file +// FUNCTION SECTION ENDS From fee4321483f29719ba3cfd06c47782b2d34dddae Mon Sep 17 00:00:00 2001 From: John-Karatka Date: Mon, 27 Jun 2022 10:07:24 -0400 Subject: [PATCH 095/184] Update SPI.adoc (#889) Added endTransaction() link to function section. --- Language/Functions/Communication/SPI.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index 7d8f82036..005f765dc 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -39,6 +39,7 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le link:../spi/spisettings[SPISettings] + link:../spi/begin[begin()] + link:../spi/begintransaction[beginTransaction()] + +link:../spi/endtransaction[endTransaction()] + link:../spi/end[end()] + link:../spi/setbitorder[setBitOrder()] + link:../spi/setclockdivider[setClockDivider()] + From cc5ff30bcfb29560b1515bdd24818ddf35f2a024 Mon Sep 17 00:00:00 2001 From: Dreamy-Z3r0 <34434717+Dreamy-Z3r0@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:07:41 +0700 Subject: [PATCH 096/184] Modification of Returns section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "The n’th character of the String" means the returned char is at index n+1 of the String, which is an incorrect description of the output. --- Language/Variables/Data Types/String/Functions/charAt.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/String/Functions/charAt.adoc b/Language/Variables/Data Types/String/Functions/charAt.adoc index a546ddd01..cb571e95a 100644 --- a/Language/Variables/Data Types/String/Functions/charAt.adoc +++ b/Language/Variables/Data Types/String/Functions/charAt.adoc @@ -35,7 +35,7 @@ Access a particular character of the String. [float] === Returns -The n'th character of the String. +The character at index n of the String. -- // OVERVIEW SECTION ENDS From fdaffa8ab53e68cdee4f3db33e63f7bf0d0e3f57 Mon Sep 17 00:00:00 2001 From: abdullah <96771929+abdullah-1307@users.noreply.github.com> Date: Mon, 4 Jul 2022 23:57:29 +0500 Subject: [PATCH 097/184] Fix monospace markup in parameters list of String != reference (#869) A missing closing backtick caused the content to be incorrectly rendered. --- .../Variables/Data Types/String/Operators/differentFrom.adoc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Language/Variables/Data Types/String/Operators/differentFrom.adoc b/Language/Variables/Data Types/String/Operators/differentFrom.adoc index c26fe47d4..7cb1ce0d7 100644 --- a/Language/Variables/Data Types/String/Operators/differentFrom.adoc +++ b/Language/Variables/Data Types/String/Operators/differentFrom.adoc @@ -7,8 +7,6 @@ subCategories: [ "StringObject Operator" ] - - = != Different From @@ -30,7 +28,7 @@ Compares two Strings for difference. The comparison is case-sensitive, meaning t [float] === Parameters -`myString1: a String variable. + +`myString1`: a String variable. + `myString2`: a String variable. From ab59ddf6312d362aa9cf2260008f0ce5ee3c8f37 Mon Sep 17 00:00:00 2001 From: ka84 <63402634+ka84@users.noreply.github.com> Date: Wed, 6 Jul 2022 23:09:17 +0300 Subject: [PATCH 098/184] Update PROGMEM.adoc fixed broken URLs --- Language/Variables/Utilities/PROGMEM.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Variables/Utilities/PROGMEM.adoc b/Language/Variables/Utilities/PROGMEM.adoc index b483ad5fe..804ec267e 100644 --- a/Language/Variables/Utilities/PROGMEM.adoc +++ b/Language/Variables/Utilities/PROGMEM.adoc @@ -17,7 +17,7 @@ subCategories: [ "Utilities" ] [float] === Description -Store data in flash (program) memory instead of SRAM. There's a description of the various http://www.arduino.cc/playground/Learning/Memory[types of memory] available on an Arduino board. +Store data in flash (program) memory instead of SRAM. There's a description of the various https://www.arduino.cc/en/Tutorial/Foundations/Memory[types of memory] available on an Arduino board. The `PROGMEM` keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "put this information into flash memory", instead of into SRAM, where it would normally go. @@ -205,7 +205,7 @@ Serial.print(F("Write something on the Serial Monitor that is stored in FLASH")) === See also [role="example"] -* #EXAMPLE# https://www.arduino.cc/playground/Learning/Memory[Types of memory available on an Arduino board^] +* #EXAMPLE# https://www.arduino.cc/en/Tutorial/Foundations/Memory[Types of memory available on an Arduino board^] [role="definition"] * #DEFINITION# link:../../data-types/array[array] From 01907336ea2c82f883692b8ad13ab1c8230365eb Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Fri, 22 Jul 2022 13:34:19 +0200 Subject: [PATCH 099/184] Highlight int nature of variable --- Language/Functions/Math/map.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Math/map.adoc b/Language/Functions/Math/map.adoc index bc69e9ba8..20cfb9bbb 100644 --- a/Language/Functions/Math/map.adoc +++ b/Language/Functions/Math/map.adoc @@ -51,7 +51,7 @@ The `map()` function uses integer math so will not generate fractions, when the [float] === Returns -The mapped value. +The mapped value as a int data type. -- // OVERVIEW SECTION ENDS From 8f587b772bd11b42d2fe5960ba0e888663f094a8 Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Fri, 22 Jul 2022 13:35:07 +0200 Subject: [PATCH 100/184] Update map.adoc --- Language/Functions/Math/map.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Math/map.adoc b/Language/Functions/Math/map.adoc index 20cfb9bbb..3731605e2 100644 --- a/Language/Functions/Math/map.adoc +++ b/Language/Functions/Math/map.adoc @@ -51,7 +51,7 @@ The `map()` function uses integer math so will not generate fractions, when the [float] === Returns -The mapped value as a int data type. +The mapped value as an int data type. -- // OVERVIEW SECTION ENDS From 0d473750a9d2d37d75e92fa06d57dfe895d92179 Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Fri, 22 Jul 2022 14:14:16 +0200 Subject: [PATCH 101/184] Revise data type declaration format --- Language/Functions/Math/map.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Math/map.adoc b/Language/Functions/Math/map.adoc index 3731605e2..7badc9be8 100644 --- a/Language/Functions/Math/map.adoc +++ b/Language/Functions/Math/map.adoc @@ -51,7 +51,7 @@ The `map()` function uses integer math so will not generate fractions, when the [float] === Returns -The mapped value as an int data type. +The mapped value. Data type: `int`. -- // OVERVIEW SECTION ENDS From 52e7c3ba6d6dc02e7f48fd6ca579aab6a410663e Mon Sep 17 00:00:00 2001 From: Suisse00 Date: Sun, 24 Jul 2022 13:26:54 -0400 Subject: [PATCH 102/184] Adding null return for ReadStringUntil or equivalent for readBytesUntil --- Language/Functions/Communication/Serial/readStringUntil.adoc | 4 +++- .../Functions/Communication/Stream/streamReadBytesUntil.adoc | 4 ++-- .../Functions/Communication/Stream/streamReadStringUntil.adoc | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Language/Functions/Communication/Serial/readStringUntil.adoc b/Language/Functions/Communication/Serial/readStringUntil.adoc index 53990e334..6ec473350 100644 --- a/Language/Functions/Communication/Serial/readStringUntil.adoc +++ b/Language/Functions/Communication/Serial/readStringUntil.adoc @@ -33,7 +33,8 @@ title: Serial.readStringUntil() [float] === Returns -The entire `String` read from the serial buffer, up to the terminator character +The entire `String` read from the serial buffer, up to the terminator character. +If the terminator character can't be found, or if there is no data before the terminator character, it will return `null`. -- // OVERVIEW SECTION ENDS @@ -46,6 +47,7 @@ The entire `String` read from the serial buffer, up to the terminator character [float] === Notes and Warnings The terminator character is discarded from the serial buffer. +If the terminator character can't be found, all read characters will be discarded. [%hardbreaks] -- diff --git a/Language/Functions/Communication/Stream/streamReadBytesUntil.adoc b/Language/Functions/Communication/Stream/streamReadBytesUntil.adoc index 1baf1ff02..e417058be 100644 --- a/Language/Functions/Communication/Stream/streamReadBytesUntil.adoc +++ b/Language/Functions/Communication/Stream/streamReadBytesUntil.adoc @@ -16,7 +16,7 @@ title: Stream.readBytesUntil() === Description `readBytesUntil()` reads characters from a stream into a buffer. The function terminates if the terminator character is detected, the determined length has been read, or it times out (see link:../streamsettimeout[setTimeout()]). The function returns the characters up to the last character before the supplied terminator. The terminator itself is not returned in the buffer. -`readBytesUntil()` returns the number of bytes placed in the buffer. A 0 means no valid data was found. +`readBytesUntil()` returns the number of bytes placed in the buffer. A 0 means the terminator character can't be found or there is no data before it. This function is part of the Stream class, and can be called by any class that inherits from it (Wire, Serial, etc). See the link:../../stream[Stream class] main page for more information. [%hardbreaks] @@ -37,7 +37,7 @@ This function is part of the Stream class, and can be called by any class that i [float] === Returns -The number of bytes placed in the buffer. +The number of bytes (excluding the terminator character) placed in the buffer if the terminator character has been found. -- // OVERVIEW SECTION ENDS diff --git a/Language/Functions/Communication/Stream/streamReadStringUntil.adoc b/Language/Functions/Communication/Stream/streamReadStringUntil.adoc index 79b818a9d..53e4378ea 100644 --- a/Language/Functions/Communication/Stream/streamReadStringUntil.adoc +++ b/Language/Functions/Communication/Stream/streamReadStringUntil.adoc @@ -33,7 +33,8 @@ This function is part of the Stream class, and can be called by any class that i [float] === Returns -The entire String read from a stream, up to the terminator character +The entire String read from a stream, up to the terminator character. +If the terminator character can't be found, or if there is no data before the terminator character, it will return `null`. -- // OVERVIEW SECTION ENDS @@ -46,6 +47,7 @@ The entire String read from a stream, up to the terminator character [float] === Notes and Warnings The terminator character is discarded from the stream. +If the terminator character can't be found, all read characters will be discarded. [%hardbreaks] -- From 59598935e72040a4379a44e97ba98ed25964a31a Mon Sep 17 00:00:00 2001 From: Suisse00 Date: Sun, 24 Jul 2022 14:49:05 -0400 Subject: [PATCH 103/184] null -> NULL --- Language/Functions/Communication/Serial/readStringUntil.adoc | 2 +- .../Functions/Communication/Stream/streamReadStringUntil.adoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Communication/Serial/readStringUntil.adoc b/Language/Functions/Communication/Serial/readStringUntil.adoc index 6ec473350..5a699bfc2 100644 --- a/Language/Functions/Communication/Serial/readStringUntil.adoc +++ b/Language/Functions/Communication/Serial/readStringUntil.adoc @@ -34,7 +34,7 @@ title: Serial.readStringUntil() [float] === Returns The entire `String` read from the serial buffer, up to the terminator character. -If the terminator character can't be found, or if there is no data before the terminator character, it will return `null`. +If the terminator character can't be found, or if there is no data before the terminator character, it will return `NULL`. -- // OVERVIEW SECTION ENDS diff --git a/Language/Functions/Communication/Stream/streamReadStringUntil.adoc b/Language/Functions/Communication/Stream/streamReadStringUntil.adoc index 53e4378ea..fea1400ab 100644 --- a/Language/Functions/Communication/Stream/streamReadStringUntil.adoc +++ b/Language/Functions/Communication/Stream/streamReadStringUntil.adoc @@ -34,7 +34,7 @@ This function is part of the Stream class, and can be called by any class that i [float] === Returns The entire String read from a stream, up to the terminator character. -If the terminator character can't be found, or if there is no data before the terminator character, it will return `null`. +If the terminator character can't be found, or if there is no data before the terminator character, it will return `NULL`. -- // OVERVIEW SECTION ENDS From a74547357f2a88e75bd079da0c4b8fda374e575f Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Mon, 8 Aug 2022 18:12:38 +0200 Subject: [PATCH 104/184] Update Language/Functions/Math/map.adoc Co-authored-by: per1234 --- Language/Functions/Math/map.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Math/map.adoc b/Language/Functions/Math/map.adoc index 7badc9be8..1c1697ae2 100644 --- a/Language/Functions/Math/map.adoc +++ b/Language/Functions/Math/map.adoc @@ -51,7 +51,7 @@ The `map()` function uses integer math so will not generate fractions, when the [float] === Returns -The mapped value. Data type: `int`. +The mapped value. Data type: `long`. -- // OVERVIEW SECTION ENDS From 1b90bd3675a6c82e87e23606939e42f4446e1590 Mon Sep 17 00:00:00 2001 From: Thomarini <62741938+Thomarini@users.noreply.github.com> Date: Tue, 9 Aug 2022 21:51:39 +0200 Subject: [PATCH 105/184] small typo error --- Language/Functions/Communication/Wire/onReceive.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Wire/onReceive.adoc b/Language/Functions/Communication/Wire/onReceive.adoc index 7b102215d..2ca8d60dd 100644 --- a/Language/Functions/Communication/Wire/onReceive.adoc +++ b/Language/Functions/Communication/Wire/onReceive.adoc @@ -1,5 +1,5 @@ --- -title: onReceieve() +title: onReceive() --- = onReceive From f0431beef401d606ceb5856089b95d557ba86cfb Mon Sep 17 00:00:00 2001 From: Mohammed Hemed <7507590+mohammedhemed77@users.noreply.github.com> Date: Sat, 13 Aug 2022 14:13:22 +0200 Subject: [PATCH 106/184] [Documentation] Missing data type (#817) * [Documentation] Missing data type In the documentation of Floating Point is this example: ``` n = 0.005; // 0.005 is a floating point constant ``` This code simply won't compile and get this error : 'n' does not name a type so this Line should be : ``` const float n = 0.005; // 0.005 is a floating point constant ``` Although this error may seem trivial for some professional , but I think it seems misleading to newcomers. * Update Language/Variables/Constants/floatingPointConstants.adoc Co-authored-by: per1234 Co-authored-by: per1234 --- Language/Variables/Constants/floatingPointConstants.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Constants/floatingPointConstants.adoc b/Language/Variables/Constants/floatingPointConstants.adoc index 43e248203..2d3defe04 100644 --- a/Language/Variables/Constants/floatingPointConstants.adoc +++ b/Language/Variables/Constants/floatingPointConstants.adoc @@ -34,7 +34,7 @@ Similar to integer constants, floating point constants are used to make code mor [source,arduino] ---- -n = 0.005; // 0.005 is a floating point constant +float n = 0.005; // 0.005 is a floating point constant ---- [%hardbreaks] From f7296fb888474b028bebab2f82bd16e80f152331 Mon Sep 17 00:00:00 2001 From: grayconstruct <77263741+grayconstruct@users.noreply.github.com> Date: Tue, 16 Aug 2022 15:33:15 -0500 Subject: [PATCH 107/184] Add readString example and notes/warnings re: line endingssections (#808) A very common mistake is not expecting readString value to have invisible \r \n characters. --- .../Communication/Serial/readString.adoc | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Language/Functions/Communication/Serial/readString.adoc b/Language/Functions/Communication/Serial/readString.adoc index 3e6822e2a..c0fa8856c 100644 --- a/Language/Functions/Communication/Serial/readString.adoc +++ b/Language/Functions/Communication/Serial/readString.adoc @@ -34,10 +34,49 @@ title: Serial.readString() === Returns A `String` read from the serial buffer + -- // OVERVIEW SECTION ENDS +// HOW TO USE SECTION STARTS +[#howtouse] +-- + +[float] +=== Example Code +Demonstrate Serial.readString() + +[source,arduino] +---- +void setup() { + Serial.begin(9600); +} + +void loop() { + Serial.println("Enter data:"); + while (Serial.available() == 0) {} //wait for data available + String teststr = Serial.readString(); //read until timeout + teststr.trim(); // remove any \r \n whitespace at the end of the String + if (teststr == "red") { + Serial.println("A primary color"); + } else { + Serial.println("Something else"); + } +} +---- +[%hardbreaks] + + +[float] +=== Notes and Warnings +The function does not terminate early if the data contains end of line characters. The returned `String` may contain carriage return and/or line feed characters if they were received. +[%hardbreaks] + +-- +// HOW TO USE SECTION ENDS + + // SEE ALSO SECTION [#see_also] -- From f6a8d7dd5eb8e60bb3d5ed3ae59fde61abdcda8c Mon Sep 17 00:00:00 2001 From: Boyd Kane <33420535+beyarkay@users.noreply.github.com> Date: Sat, 3 Sep 2022 21:06:11 +0200 Subject: [PATCH 108/184] Describe `noInterrupts` disabling USB handshakes (#891) --- Language/Functions/Interrupts/noInterrupts.adoc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Interrupts/noInterrupts.adoc b/Language/Functions/Interrupts/noInterrupts.adoc index c7e413dba..b925094d7 100644 --- a/Language/Functions/Interrupts/noInterrupts.adoc +++ b/Language/Functions/Interrupts/noInterrupts.adoc @@ -17,7 +17,7 @@ subCategories: [ "Interrupts" ] [float] === Description -Disables interrupts (you can re-enable them with `interrupts()`). Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code. +Disables interrupts (you can re-enable them with link:../interrupts[`interrupts()`]). Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code. [%hardbreaks] @@ -61,6 +61,13 @@ void loop() { // other code here } ---- +[%hardbreaks] + + +[float] +=== Notes and Warnings +Note that disabling interrupts on the Arduino boards with native USB capabilities (e.g., link:https://docs.arduino.cc/hardware/leonardo[Leonardo^]) will make the board +not appear in the Port menu, since this disables its USB capability. -- // HOW TO USE SECTION ENDS From e06c4042a5c52ce59f15dcf072a00e53085c5350 Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Tue, 6 Sep 2022 21:31:04 +0200 Subject: [PATCH 109/184] Add relevent links to other math functions (#845) --- Language/Functions/Math/abs.adoc | 9 +++++++++ Language/Functions/Math/constrain.adoc | 9 +++++++++ Language/Functions/Math/map.adoc | 9 +++++++++ Language/Functions/Math/max.adoc | 10 ++++++++++ Language/Functions/Math/min.adoc | 9 +++++++++ Language/Functions/Math/pow.adoc | 12 +++++++++--- Language/Functions/Math/sq.adoc | 9 +++++++++ Language/Functions/Math/sqrt.adoc | 9 +++++++++ 8 files changed, 73 insertions(+), 3 deletions(-) diff --git a/Language/Functions/Math/abs.adoc b/Language/Functions/Math/abs.adoc index d494e4c1f..5e575abb2 100644 --- a/Language/Functions/Math/abs.adoc +++ b/Language/Functions/Math/abs.adoc @@ -99,5 +99,14 @@ a++; // keep other math outside the function [float] === See also +[role="language"] +* #LANGUAGE# link:../constrain[constrain()] +* #LANGUAGE# link:../map[map()] +* #LANGUAGE# link:../max[max()] +* #LANGUAGE# link:../min[min()] +* #LANGUAGE# link:../pow[pow()] +* #LANGUAGE# link:../sq[sq()] +* #LANGUAGE# link:../sqrt[sqrt()] + -- // SEE ALSO SECTION ENDS diff --git a/Language/Functions/Math/constrain.adoc b/Language/Functions/Math/constrain.adoc index 5ba9436ee..7abb8f2f4 100644 --- a/Language/Functions/Math/constrain.adoc +++ b/Language/Functions/Math/constrain.adoc @@ -88,5 +88,14 @@ int constrainedInput = constrain(input, minimumValue, maximumValue); [float] === See also +[role="language"] +* #LANGUAGE# link:../abs[abs()] +* #LANGUAGE# link:../map[map()] +* #LANGUAGE# link:../max[max()] +* #LANGUAGE# link:../min[min()] +* #LANGUAGE# link:../pow[pow()] +* #LANGUAGE# link:../sq[sq()] +* #LANGUAGE# link:../sqrt[sqrt()] + -- // SEE ALSO SECTION ENDS diff --git a/Language/Functions/Math/map.adoc b/Language/Functions/Math/map.adoc index 1c1697ae2..ee97cf762 100644 --- a/Language/Functions/Math/map.adoc +++ b/Language/Functions/Math/map.adoc @@ -109,5 +109,14 @@ As previously mentioned, the map() function uses integer math. So fractions migh [float] === See also +[role="language"] +* #LANGUAGE# link:../abs[abs()] +* #LANGUAGE# link:../constrain[constrain()] +* #LANGUAGE# link:../max[max()] +* #LANGUAGE# link:../min[min()] +* #LANGUAGE# link:../pow[pow()] +* #LANGUAGE# link:../sq[sq()] +* #LANGUAGE# link:../sqrt[sqrt()] + -- // SEE ALSO SECTION ENDS diff --git a/Language/Functions/Math/max.adoc b/Language/Functions/Math/max.adoc index b3ec6d8d1..1ea570a59 100644 --- a/Language/Functions/Math/max.adoc +++ b/Language/Functions/Math/max.adoc @@ -83,5 +83,15 @@ a--; // keep other math outside the function [float] === See also +[role="language"] +* #LANGUAGE# link:../abs[abs()] +* #LANGUAGE# link:../constrain[constrain()] +* #LANGUAGE# link:../map[map()] +* #LANGUAGE# link:../min[min()] +* #LANGUAGE# link:../pow[pow()] +* #LANGUAGE# link:../sq[sq()] +* #LANGUAGE# link:../sqrt[sqrt()] + + -- // SEE ALSO SECTION ENDS diff --git a/Language/Functions/Math/min.adoc b/Language/Functions/Math/min.adoc index 77054141b..fc8c663c8 100644 --- a/Language/Functions/Math/min.adoc +++ b/Language/Functions/Math/min.adoc @@ -82,5 +82,14 @@ a++; // use this instead - keep other math outside the function [float] === See also +[role="language"] +* #LANGUAGE# link:../abs[abs()] +* #LANGUAGE# link:../constrain[constrain()] +* #LANGUAGE# link:../map[map()] +* #LANGUAGE# link:../max[max()] +* #LANGUAGE# link:../pow[pow()] +* #LANGUAGE# link:../sq[sq()] +* #LANGUAGE# link:../sqrt[sqrt()] + -- // SEE ALSO SECTION ENDS diff --git a/Language/Functions/Math/pow.adoc b/Language/Functions/Math/pow.adoc index 4beded9a1..feda5a6d9 100644 --- a/Language/Functions/Math/pow.adoc +++ b/Language/Functions/Math/pow.adoc @@ -66,9 +66,15 @@ See the (http://arduino.cc/playground/Main/Fscale[fscale]) sketch for a more com [float] === See also -[role="definition"] -* #DEFINITION# link:../../../variables/data-types/float[float] -* #DEFENITION# link:../../../variables/data-types/double[double] +[role="language"] +* #LANGUAGE# link:../abs[abs()] +* #LANGUAGE# link:../constrain[constrain()] +* #LANGUAGE# link:../map[map()] +* #LANGUAGE# link:../max[max()] +* #LANGUAGE# link:../min[min()] +* #LANGUAGE# link:../sq[sq()] +* #LANGUAGE# link:../sqrt[sqrt()] + -- // SEE ALSO SECTION ENDS diff --git a/Language/Functions/Math/sq.adoc b/Language/Functions/Math/sq.adoc index 484d523e3..ac403498d 100644 --- a/Language/Functions/Math/sq.adoc +++ b/Language/Functions/Math/sq.adoc @@ -72,5 +72,14 @@ int inputSquared = sq(input); [float] === See also +[role="language"] +* #LANGUAGE# link:../abs[abs()] +* #LANGUAGE# link:../constrain[constrain()] +* #LANGUAGE# link:../map[map()] +* #LANGUAGE# link:../max[max()] +* #LANGUAGE# link:../min[min()] +* #LANGUAGE# link:../pow[pow()] +* #LANGUAGE# link:../sqrt[sqrt()] + -- // SEE ALSO SECTION ENDS diff --git a/Language/Functions/Math/sqrt.adoc b/Language/Functions/Math/sqrt.adoc index 25a918575..00f601091 100644 --- a/Language/Functions/Math/sqrt.adoc +++ b/Language/Functions/Math/sqrt.adoc @@ -46,5 +46,14 @@ The number's square root. Data type: `double`. [float] === See also +[role="language"] +* #LANGUAGE# link:../abs[abs()] +* #LANGUAGE# link:../constrain[constrain()] +* #LANGUAGE# link:../map[map()] +* #LANGUAGE# link:../max[max()] +* #LANGUAGE# link:../min[min()] +* #LANGUAGE# link:../pow[pow()] +* #LANGUAGE# link:../sq[sq()] + -- // SEE ALSO SECTION ENDS From 3d81819a42f5efbaf6be7c28c13211e4120b4d24 Mon Sep 17 00:00:00 2001 From: pcamp Date: Fri, 11 Nov 2022 08:27:46 -0600 Subject: [PATCH 110/184] Fixed links to example code. --- Language/Variables/Data Types/array.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/array.adoc b/Language/Variables/Data Types/array.adoc index 9e16293a0..ccbbf2fd4 100644 --- a/Language/Variables/Data Types/array.adoc +++ b/Language/Variables/Data Types/array.adoc @@ -83,7 +83,7 @@ for (byte i = 0; i < 5; i = i + 1) { [float] === Example Code -For a complete program that demonstrates the use of arrays, see the (http://www.arduino.cc/en/Tutorial/KnightRider[Knight Rider example]) from the (http://www.arduino.cc/en/Main/LearnArduino[Tutorials]). +For a complete program that demonstrates the use of arrays, see the (https://docs.arduino.cc/built-in-examples/control-structures/Arrays[How to Use Arrays example]) from the (https://docs.arduino.cc/built-in-examples[Built-in Examples]). -- // HOW TO USE SECTION ENDS From 33bed7f62597e335c87d65d6776e13d8a75f7e84 Mon Sep 17 00:00:00 2001 From: Carlos Pereira Atencio <4189262+carlosperate@users.noreply.github.com> Date: Sun, 25 Dec 2022 19:07:18 +0000 Subject: [PATCH 111/184] Remove return value from Wire.clearWireTimeoutFlag() documentation. As it's not meant to return anything. --- Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc b/Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc index b5a44711f..66bb41466 100644 --- a/Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc +++ b/Language/Functions/Communication/Wire/clearWireTimeoutFlag.adoc @@ -26,7 +26,7 @@ None. [float] === Returns -* bool: The current value of the flag +None. [float] === Portability Notes From 999aeeede02cc5a4a77a1f82c6defa516d448cba Mon Sep 17 00:00:00 2001 From: BloodyNewbie <43654884+BloodyNewbie@users.noreply.github.com> Date: Wed, 18 Jan 2023 21:20:52 +0100 Subject: [PATCH 112/184] Update bit.adoc with allowed range of n bit(n) with n > 31 do not return reasonable values. This should be mentioned --- Language/Functions/Bits and Bytes/bit.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Bits and Bytes/bit.adoc b/Language/Functions/Bits and Bytes/bit.adoc index 7b4636411..6127e2802 100644 --- a/Language/Functions/Bits and Bytes/bit.adoc +++ b/Language/Functions/Bits and Bytes/bit.adoc @@ -28,7 +28,7 @@ Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc [float] === Parameters -`n`: the bit whose value to compute +`n`: the bit whose value to compute. 0 <= n < 32 (as it is intended to reflect the bits up to 31 of a uint32) [float] From 0cbe21fda685f7cd04ab6c2f3c8afba48a39e496 Mon Sep 17 00:00:00 2001 From: Gonzalo Martinez Date: Mon, 10 Apr 2023 00:24:00 -0600 Subject: [PATCH 113/184] Print class documentation created --- Language/Functions/Communication/Print.adoc | 61 +++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Language/Functions/Communication/Print.adoc diff --git a/Language/Functions/Communication/Print.adoc b/Language/Functions/Communication/Print.adoc new file mode 100644 index 000000000..31b61ba5d --- /dev/null +++ b/Language/Functions/Communication/Print.adoc @@ -0,0 +1,61 @@ +--- +title: Print +categories: [ "Functions" ] +subCategories: [ "Communication" ] +--- + + + + += Print + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +The Print class is an abstract base class that provides a common interface for printing data to different output devices. It defines several methods that allow printing data in different formats. + +Print class is related to several libraries in Arduino that use the printing funcionality to interact with devices such as Serial Monitor, LCD Screen, printers, etc. + +Some of the libraries that use the Print class are: + +* link:../serial[Serial] +* link:https://reference.arduino.cc/reference/en/libraries/liquidcrystal/[LiquidCrystal] +* link:https://www.arduino.cc/en/Reference/Ethernet[Ethernet] +* link:https://reference.arduino.cc/reference/en/libraries/wifi/wificlient/[Wifi] + + +-- +// OVERVIEW SECTION ENDS + + +// FUNCTIONS SECTION STARTS +[#functions] +-- + +''' + +[float] +=== Functions +link:https://www.arduino.cc/reference/en/language/functions/communication/wire/write/[write()] + +link:https://www.arduino.cc/reference/en/language/functions/communication/serial/print/[print()] + +link:https://www.arduino.cc/reference/en/language/functions/communication/serial/println/[println()] + +''' + +-- +// FUNCTIONS SECTION ENDS + + +// SEE ALSO SECTION +[#see_also] +-- + +[float] +=== See also + +-- +// SEE ALSO SECTION ENDS \ No newline at end of file From fb367451d62efe413e5ddf8d6c693298894d82c6 Mon Sep 17 00:00:00 2001 From: seaxwi <71350948+seaxwi@users.noreply.github.com> Date: Fri, 16 Jun 2023 16:36:55 +0200 Subject: [PATCH 114/184] Update PWM table with UNO R4 and GIGA R1 --- Language/Functions/Analog IO/analogWrite.adoc | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 95402cba0..35f8fffef 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -17,24 +17,28 @@ subCategories: [ "Analog I/O" ] [float] === Description -Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to `analogWrite()`, the pin will generate a steady rectangular wave of the specified duty cycle until the next call to `analogWrite()` (or a call to `digitalRead()` or `digitalWrite()`) on the same pin. +Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to `analogWrite()`, the pin will generate a steady rectangular wave of the specified duty cycle until the next call to `analogWrite()` (or a call to `digitalRead()` or `digitalWrite()`) on the same pin. + [options="header"] -|======================================================================================================== -| Board | PWM Pins | PWM Frequency -| Uno, Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) -| Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) -| Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) -| Uno WiFi Rev2, Nano Every | 3, 5, 6, 9, 10 | 976 Hz -| MKR boards * | 0 - 8, 10, A3, A4 | 732 Hz -| MKR1000 WiFi * | 0 - 8, 10, 11, A3, A4 | 732 Hz -| Zero * | 3 - 13, A0, A1 | 732 Hz -| Nano 33 IoT * | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz -| Nano 33 BLE/BLE Sense | 1 - 13, A0 - A7 | 500 Hz -| Due ** | 2-13 | 1000 Hz -| 101 | 3, 5, 6, 9 | pins 3 and 9: 490 Hz, pins 5 and 6: 980 Hz -|======================================================================================================== -{empty}* In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + -{empty}** In addition to PWM capabilities on the pins noted above, the Due has true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. +|========================================================================================================================= +| Board | PWM Pins * | PWM Frequency +| UNO (R3 and earlier), Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) +| UNO R4 (Minima, WiFi) | 3, 5, 6, 9, 10, 11 | 490 Hz +| Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) +| GIGA R1 | 2 - 13 | +| Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) +| UNO WiFi Rev2, Nano Every | 3, 5, 6, 9, 10 | 976 Hz +| MKR boards ** | 0 - 8, 10, A3, A4 | 732 Hz +| MKR1000 WiFi ** | 0 - 8, 10, 11, A3, A4 | 732 Hz +| Zero ** | 3 - 13, A0, A1 | 732 Hz +| Nano 33 IoT ** | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz +| Nano 33 BLE/BLE Sense | 1 - 13, A0 - A7 | 500 Hz +| Due \*** | 2-13 | 1000 Hz +| 101 | 3, 5, 6, 9 | pins 3 and 9: 490 Hz, pins 5 and 6: 980 Hz +|========================================================================================================================= +{empty}* These pins are officially supported PWM pins. While some boards have additional pins capable of PWM, using them is recommended only for advanced users that can account for timer availability and potential conflicts with other uses of those pins. + +{empty}** In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + +{empty}pass:specialcharacters[***] In addition to PWM capabilities on the pins noted above, the Due has true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. [%hardbreaks] From bd835df2602ecfecb606222061cd728ad17504f1 Mon Sep 17 00:00:00 2001 From: seaxwi <71350948+seaxwi@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:41:20 +0200 Subject: [PATCH 115/184] Update Language/Functions/Analog IO/analogWrite.adoc Co-authored-by: per1234 --- Language/Functions/Analog IO/analogWrite.adoc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 35f8fffef..273f7a907 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -21,24 +21,25 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C [options="header"] |========================================================================================================================= -| Board | PWM Pins * | PWM Frequency +|========================================================================================================================= +| Board | PWM Pins +*+ | PWM Frequency | UNO (R3 and earlier), Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) | UNO R4 (Minima, WiFi) | 3, 5, 6, 9, 10, 11 | 490 Hz | Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) | GIGA R1 | 2 - 13 | | Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) | UNO WiFi Rev2, Nano Every | 3, 5, 6, 9, 10 | 976 Hz -| MKR boards ** | 0 - 8, 10, A3, A4 | 732 Hz -| MKR1000 WiFi ** | 0 - 8, 10, 11, A3, A4 | 732 Hz -| Zero ** | 3 - 13, A0, A1 | 732 Hz -| Nano 33 IoT ** | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz +| MKR boards +**+ | 0 - 8, 10, A3, A4 | 732 Hz +| MKR1000 WiFi +**+ | 0 - 8, 10, 11, A3, A4 | 732 Hz +| Zero +**+ | 3 - 13, A0, A1 | 732 Hz +| Nano 33 IoT +**+ | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz | Nano 33 BLE/BLE Sense | 1 - 13, A0 - A7 | 500 Hz -| Due \*** | 2-13 | 1000 Hz +| Due +***+ | 2-13 | 1000 Hz | 101 | 3, 5, 6, 9 | pins 3 and 9: 490 Hz, pins 5 and 6: 980 Hz |========================================================================================================================= -{empty}* These pins are officially supported PWM pins. While some boards have additional pins capable of PWM, using them is recommended only for advanced users that can account for timer availability and potential conflicts with other uses of those pins. + -{empty}** In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + -{empty}pass:specialcharacters[***] In addition to PWM capabilities on the pins noted above, the Due has true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. ++*+ These pins are officially supported PWM pins. While some boards have additional pins capable of PWM, using them is recommended only for advanced users that can account for timer availability and potential conflicts with other uses of those pins. + ++**+ In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + ++***+ In addition to PWM capabilities on the pins noted above, the Due has true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. [%hardbreaks] From ed0987b4adcdd4b9bc16b54d319c0706c37011fd Mon Sep 17 00:00:00 2001 From: seaxwi <71350948+seaxwi@users.noreply.github.com> Date: Wed, 5 Jul 2023 19:00:30 +0200 Subject: [PATCH 116/184] Add PWM frequency for GIGA R1 --- Language/Functions/Analog IO/analogWrite.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 273f7a907..e49efe1ca 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -26,7 +26,7 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C | UNO (R3 and earlier), Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) | UNO R4 (Minima, WiFi) | 3, 5, 6, 9, 10, 11 | 490 Hz | Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) -| GIGA R1 | 2 - 13 | +| GIGA R1 | 2 - 13 | 500 Hz | Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) | UNO WiFi Rev2, Nano Every | 3, 5, 6, 9, 10 | 976 Hz | MKR boards +**+ | 0 - 8, 10, A3, A4 | 732 Hz From b43dfa96214b403bb12074503f867a3765e5a6fa Mon Sep 17 00:00:00 2001 From: Hannes Siebeneicher Date: Thu, 7 Sep 2023 16:44:53 +0200 Subject: [PATCH 117/184] Fix do..while example --- Language/Structure/Control Structure/doWhile.adoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Language/Structure/Control Structure/doWhile.adoc b/Language/Structure/Control Structure/doWhile.adoc index c79421917..8651f957e 100644 --- a/Language/Structure/Control Structure/doWhile.adoc +++ b/Language/Structure/Control Structure/doWhile.adoc @@ -49,11 +49,15 @@ do { [source,arduino] ---- +// initialize x and i with a value of 0 int x = 0; +int i = 0; + do { delay(50); // wait for sensors to stabilize x = readSensors(); // check the sensors -} while (x < 100); + i++; // increase i by 1 +} while (i < 100); // repeat 100 times ---- From 9a8c2324a0fcd22088ec8004ccd63d1f9512e450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 11 Sep 2023 10:24:46 +0200 Subject: [PATCH 118/184] Add new boards to attachInterrupt api --- Language/Functions/External Interrupts/attachInterrupt.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index fe5489807..d78cb147b 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -21,6 +21,7 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you |=================================================== |Board |Digital Pins Usable For Interrupts |Uno, Nano, Mini, other 328-based |2, 3 +|UNO R4 Minima, UNO R4 WiFi |2, 3 |Uno WiFi Rev.2, Nano Every |all digital pins |Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 (*pins 20 & 21* are not available to use for interrupts while they are used for I2C communication) |Micro, Leonardo, other 32u4-based |0, 1, 2, 3, 7 @@ -28,6 +29,8 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you |MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2 |Nano 33 IoT |2, 3, 9, 10, 11, 13, A1, A5, A7 |Nano 33 BLE, Nano 33 BLE Sense |all pins +|Nano RP2040 Connect |all pins except A6/A7 +|Nano ESP32 |all pins |Due |all digital pins |101 |all digital pins (Only pins 2, 5, 7, 8, 10, 11, 12, 13 work with *CHANGE*) |=================================================== From eb7bb37d015693c92bd07c7fdf89a0bf851ec99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 11 Sep 2023 10:34:48 +0200 Subject: [PATCH 119/184] Update attachInterrupt.adoc --- Language/Functions/External Interrupts/attachInterrupt.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index d78cb147b..461ab5706 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -31,6 +31,7 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you |Nano 33 BLE, Nano 33 BLE Sense |all pins |Nano RP2040 Connect |all pins except A6/A7 |Nano ESP32 |all pins +|GIGA R1 WiFi |all pins |Due |all digital pins |101 |all digital pins (Only pins 2, 5, 7, 8, 10, 11, 12, 13 work with *CHANGE*) |=================================================== From cc5a99f3d713d190fc2cb039133f0244828d285f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 31 Oct 2023 16:52:01 +0100 Subject: [PATCH 120/184] Explain that tone() is non-blocking. #836 --- Language/Functions/Advanced IO/tone.adoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Advanced IO/tone.adoc b/Language/Functions/Advanced IO/tone.adoc index 04b4debad..3468cd109 100644 --- a/Language/Functions/Advanced IO/tone.adoc +++ b/Language/Functions/Advanced IO/tone.adoc @@ -56,7 +56,10 @@ Nothing [float] === Notes and Warnings -If you want to play different pitches on multiple pins, you need to call `noTone()` on one pin before calling `tone()` on the next pin. + +* If you want to play different pitches on multiple pins, you need to call `noTone()` on one pin before calling `tone()` on the next pin. +* This function is non-blocking, which means that even if you provide the `duration` parameter the sketch execution will continue immediately even if the tone hasn't finished playing. + [%hardbreaks] -- From 6bed39554dd50a3db9d5beae02195195f7989c60 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 31 Oct 2023 17:00:23 +0100 Subject: [PATCH 121/184] Clarify array initialization. #813 --- Language/Variables/Data Types/array.adoc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Language/Variables/Data Types/array.adoc b/Language/Variables/Data Types/array.adoc index ccbbf2fd4..1825020c8 100644 --- a/Language/Variables/Data Types/array.adoc +++ b/Language/Variables/Data Types/array.adoc @@ -19,16 +19,21 @@ An array is a collection of variables that are accessed with an index number. Ar All of the methods below are valid ways to create (declare) an array. [source,arduino] ---- + // Declare an array of a given length without initializing the values: int myInts[6]; - int myPins[] = {2, 4, 8, 3, 6}; + + // Declare an array without explicitely choosing a size (the compiler + // counts the elements and creates an array of the appropriate size): + int myPins[] = {2, 4, 8, 3, 6, 4}; + + // Declare an array of a given length and initialize its values: int mySensVals[5] = {2, 4, -8, 3, 2}; + + // When declaring an array of type char, you'll need to make it longer + // by one element to hold the required the null termination character: char message[6] = "hello"; ---- -You can declare an array without initializing it as in myInts. -{empty} + -In myPins we declare an array without explicitly choosing a size. The compiler counts the elements and creates an array of the appropriate size. -{empty} + -Finally you can both initialize and size your array, as in mySensVals. Note that when declaring an array of type char, one more element than your initialization is required, to hold the required null character. + [%hardbreaks] [float] From 31b6de3edbae258eab96f42da5f61e67d201d2b4 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 31 Oct 2023 17:19:20 +0100 Subject: [PATCH 122/184] Explain that SPI.begin() must be called before SPI.beginTransaction() --- Language/Functions/Communication/SPI/beginTransaction.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Communication/SPI/beginTransaction.adoc b/Language/Functions/Communication/SPI/beginTransaction.adoc index 3b5147aff..ae299ca02 100644 --- a/Language/Functions/Communication/SPI/beginTransaction.adoc +++ b/Language/Functions/Communication/SPI/beginTransaction.adoc @@ -11,7 +11,7 @@ title: SPI.beginTransaction() [float] === Description -Initializes the SPI bus using the defined link:../spisettings[SPISettings]. +Initializes the SPI bus. Note that calling link:../begin[SPI.begin()] is required before calling this one. [float] @@ -21,7 +21,7 @@ Initializes the SPI bus using the defined link:../spisettings[SPISettings]. [float] === Parameters -mySettings: the chosen settings according to link:../spisettings[SPISettings]. +mySettings: the chosen settings (see link:../spisettings[SPISettings]). [float] From 35878f27f19982b18ddfd0dc22070271f7502e5e Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Wed, 8 Nov 2023 11:34:42 +0100 Subject: [PATCH 123/184] Multiple fixes to bitshiftRight.adoc A few corrections: * The allowed types for the left operand are not only `byte`, `int` and `long`: any integer type is allowed. In fact, an example further down uses `unsigned int`. * The right operand should be positive and less than the width of the left operand, otherwise the behavior is undefined. The condition "<= 32" is incorrect, even on 32-bit architectures. * Sign extension is not done "for esoteric historical reasons": it is required for the shift to perform a division by powers of two. Also, specify that the bits that fall off are discarded, reword some sentences, format variable names as code, and add the decimal results in comments. --- .../Bitwise Operators/bitshiftRight.adoc | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Language/Structure/Bitwise Operators/bitshiftRight.adoc b/Language/Structure/Bitwise Operators/bitshiftRight.adoc index 53715a33a..444665f96 100644 --- a/Language/Structure/Bitwise Operators/bitshiftRight.adoc +++ b/Language/Structure/Bitwise Operators/bitshiftRight.adoc @@ -29,8 +29,8 @@ The right shift operator `>>` causes the bits of the left operand to be shifted [float] === Parameters -`variable`: Allowed data types: `byte`, `int`, `long`. + -`number_of_bits`: a number that is < = 32. Allowed data types: `int`. +`variable`: Allowed data types: any integer type (`byte`, `short`, `int`, `long`, `unsigned short`...). + +`number_of_bits`: a positive number smaller than the bit-width of `variable`. Allowed data types: `int`. -- // OVERVIEW SECTION ENDS @@ -47,29 +47,29 @@ The right shift operator `>>` causes the bits of the left operand to be shifted [source,arduino] ---- int a = 40; // binary: 0000000000101000 -int b = a >> 3; // binary: 0000000000000101, or 5 in decimal +int b = a >> 3; // binary: 0000000000000101, decimal: 5 ---- [%hardbreaks] [float] === Notes and Warnings -When you shift x right by y bits (x >> y), and the highest bit in x is a 1, the behavior depends on the exact data type of x. If x is of type int, the highest bit is the sign bit, determining whether x is negative or not, as we have discussed above. In that case, the sign bit is copied into lower bits, for esoteric historical reasons: +When you shift `x` right by `y` bits (`x >> y`), the `y` rightmost bits of `x` “fall off” and are discarded. If `x` has an unsigned type (e.g. `unsigned int`), the `y` leftmost bits of the result are filled with zeroes. If `x` has a signed type (e.g. `int`), its leftmost bit is the sign bit, which determines whether it is positive or negative. In this case, the `y` leftmost bits of the result are filled with copies of the sign bit. This behavior, called “sign extension”, ensures the result has the same sign as `x`. [source,arduino] ---- -int x = -16; // binary: 1111111111110000 +int x = -16; // binary: 1111111111110000 int y = 3; -int result = x >> y; // binary: 1111111111111110 +int result = x >> y; // binary: 1111111111111110, decimal: -2 ---- -This behavior, called sign extension, is often not the behavior you want. Instead, you may wish zeros to be shifted in from the left. It turns out that the right shift rules are different for unsigned int expressions, so you can use a typecast to suppress ones being copied from the left: +This may not be the behavior you want. If you instead want zeros to be shifted in from the left, you can use a typecast to suppress sign extension: [source,arduino] ---- -int x = -16; // binary: 1111111111110000 +int x = -16; // binary: 1111111111110000 int y = 3; -int result = (unsigned int)x >> y; // binary: 0001111111111110 +int result = (unsigned int)x >> y; // binary: 0001111111111110, decimal: 8190 ---- -Sign extension causes that you can use the right-shift operator `>>` as a way to divide by powers of 2, even negative numbers. For example: +Sign extension causes the right-shift operator `>>` to perform a division by powers of 2, even with negative numbers. For example: [source,arduino] ---- From 38037ccd47d8fae475683ecb8602abd82a5d6871 Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Thu, 9 Nov 2023 12:20:53 +0100 Subject: [PATCH 124/184] PROGMEM.adoc: remove false implications Remove two false implications from PROGMEM.adoc: 1. That PROGMEM costs flash space (constants go to flash no matter what, PROGMEM only prevents them from being copied to ram at start up). 2. That reading PROGMEM data incurs the cost of an extra flash-to-SRAM copy (no extra copy: an SRAM-to-CPU copy is replaced by a flash-to-CPU copy). Also, add an empty line after `#include ` for better formatting. Fixes #739. --- Language/Variables/Utilities/PROGMEM.adoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Language/Variables/Utilities/PROGMEM.adoc b/Language/Variables/Utilities/PROGMEM.adoc index 2c8a5de8a..2006bc5ff 100644 --- a/Language/Variables/Utilities/PROGMEM.adoc +++ b/Language/Variables/Utilities/PROGMEM.adoc @@ -17,16 +17,17 @@ subCategories: [ "Utilities" ] [float] === Description -Store data in flash (program) memory instead of SRAM. There's a description of the various https://www.arduino.cc/en/Tutorial/Foundations/Memory[types of memory] available on an Arduino board. +Keep constant data in flash (program) memory only, instead of copying it to SRAM when the program starts. There's a description of the various https://www.arduino.cc/en/Tutorial/Foundations/Memory[types of memory] available on an Arduino board. -The `PROGMEM` keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "put this information into flash memory", instead of into SRAM, where it would normally go. +The `PROGMEM` keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "keep this information in flash memory only", instead of copying it to SRAM at start up, like it would normally do. PROGMEM is part of the link:http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h] library. It is included automatically in modern versions of the IDE. However, if you are using an IDE version below 1.0 (2011), you'll first need to include the library at the top of your sketch, like this: `#include ` + While `PROGMEM` could be used on a single variable, it is really only worth the fuss if you have a larger block of data that needs to be stored, which is usually easiest in an array, (or another C++ data structure beyond our present discussion). -Using `PROGMEM` is also a two-step procedure. After getting the data into Flash memory, it requires special methods (functions), also defined in the link:http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h] library, to read the data from program memory back into SRAM, so we can do something useful with it. +Using `PROGMEM` is a two-step procedure. Once a variable has been defined with `PROGMEM`, it cannot be read like a regular SRAM-based variable: you have to read it using specific functions, also defined in link:http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h]. [%hardbreaks] From c1fa7587f49c5c1f8a42bf524510922487b3ab93 Mon Sep 17 00:00:00 2001 From: J-J-B-J Date: Sun, 12 Nov 2023 12:03:30 +1100 Subject: [PATCH 125/184] Update print.adoc Fix typo: "length" was spelled "lenght" --- Language/Functions/Communication/Serial/print.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Serial/print.adoc b/Language/Functions/Communication/Serial/print.adoc index eb2d5732f..a14c9cec1 100644 --- a/Language/Functions/Communication/Serial/print.adoc +++ b/Language/Functions/Communication/Serial/print.adoc @@ -100,7 +100,7 @@ void loop() { for (int x = 0; x < 64; x++) { // only part of the ASCII chart, change to suit // print it out in many formats: Serial.print(x); // print as an ASCII-encoded decimal - same as "DEC" - Serial.print("\t\t"); // prints two tabs to accomodate the label lenght + Serial.print("\t\t"); // prints two tabs to accomodate the label length Serial.print(x, DEC); // print as an ASCII-encoded decimal Serial.print("\t"); // prints a tab From 00a094c11b669a821a021cbc42db6ade8010cc7c Mon Sep 17 00:00:00 2001 From: Edgar Bonet Date: Thu, 23 Feb 2023 21:33:51 +0100 Subject: [PATCH 126/184] keyboardBegin.adoc: add pt_PT and hu_HU keyboard layouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Version 1.0.5 of the Keyboard library added the Portuguese and the Hungarian keyboard layouts. Update the documentation of Keyboard.begin() accordingly. Co-authored-by: Karl Söderby <35461661+karlsoderby@users.noreply.github.com> --- Language/Functions/USB/Keyboard/keyboardBegin.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Language/Functions/USB/Keyboard/keyboardBegin.adoc b/Language/Functions/USB/Keyboard/keyboardBegin.adoc index bdeaab7e7..52e352203 100644 --- a/Language/Functions/USB/Keyboard/keyboardBegin.adoc +++ b/Language/Functions/USB/Keyboard/keyboardBegin.adoc @@ -38,7 +38,9 @@ Currently, the library supports the following national keyboard layouts: * `KeyboardLayout_en_US`: USA * `KeyboardLayout_es_ES`: Spain * `KeyboardLayout_fr_FR`: France +* `KeyboardLayout_hu_HU`: Hungary * `KeyboardLayout_it_IT`: Italy +* `KeyboardLayout_pt_PT`: Portugal * `KeyboardLayout_sv_SE`: Sweden From abc3fa7378ac4d208d612532b7272d522716254a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Hyl=C3=A9n?= Date: Thu, 16 Nov 2023 12:04:36 +0100 Subject: [PATCH 127/184] Update analogWrite.adoc --- Language/Functions/Analog IO/analogWrite.adoc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 5e9e4f25b..76eb3c261 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -21,26 +21,26 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C [options="header"] -|========================================================================================================================= |========================================================================================================================= | Board | PWM Pins +*+ | PWM Frequency | UNO (R3 and earlier), Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) -| UNO R4 (Minima, WiFi) | 3, 5, 6, 9, 10, 11 | 490 Hz +| UNO R4 (Minima, WiFi) +*+ | 3, 5, 6, 9, 10, 11 | 490 Hz | Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) -| GIGA R1 | 2 - 13 | 500 Hz +| GIGA R1** | 2 - 13 | 500 Hz | Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) | UNO WiFi Rev2, Nano Every | 3, 5, 6, 9, 10 | 976 Hz -| MKR boards +**+ | 0 - 8, 10, A3, A4 | 732 Hz +| MKR boards +*+ | 0 - 8, 10, A3, A4 | 732 Hz | MKR1000 WiFi +**+ | 0 - 8, 10, 11, A3, A4 | 732 Hz | Zero +**+ | 3 - 13, A0, A1 | 732 Hz | Nano 33 IoT +**+ | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz | Nano 33 BLE/BLE Sense +****+ | 1 - 13, A0 - A7 | 500 Hz | Due +***+ | 2-13 | 1000 Hz | 101 | 3, 5, 6, 9 | pins 3 and 9: 490 Hz, pins 5 and 6: 980 Hz -|========================================================================================================================= +|======================================================================================================================= + +*+ These pins are officially supported PWM pins. While some boards have additional pins capable of PWM, using them is recommended only for advanced users that can account for timer availability and potential conflicts with other uses of those pins. + -+**+ In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, and Zero boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + -+***+ In addition to PWM capabilities on the pins noted above, the Due has true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. ++**+ In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, Zero and UNO R4 boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + ++***+ In addition to PWM capabilities on the pins noted above, the Due and GIGA R1 boards have true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. +****+ Only 4 different pins can be used at the same time. Enabling PWM on more than 4 pins will abort the running sketch and require resetting the board to upload a new sketch again. + [%hardbreaks] From e05ba5b96f5b9e9cce137d335380ff5288615762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Hyl=C3=A9n?= Date: Thu, 16 Nov 2023 12:06:50 +0100 Subject: [PATCH 128/184] Update analogWrite.adoc --- Language/Functions/Analog IO/analogWrite.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index 76eb3c261..f6fbcd560 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -36,7 +36,7 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C | Nano 33 BLE/BLE Sense +****+ | 1 - 13, A0 - A7 | 500 Hz | Due +***+ | 2-13 | 1000 Hz | 101 | 3, 5, 6, 9 | pins 3 and 9: 490 Hz, pins 5 and 6: 980 Hz -|======================================================================================================================= +|========================================================================================================================= +*+ These pins are officially supported PWM pins. While some boards have additional pins capable of PWM, using them is recommended only for advanced users that can account for timer availability and potential conflicts with other uses of those pins. + +**+ In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, Zero and UNO R4 boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + From 00f2a168b917de22ba1d61fd147d2bb387ab23df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Hyl=C3=A9n?= Date: Thu, 16 Nov 2023 12:09:31 +0100 Subject: [PATCH 129/184] Update analogWrite.adoc --- Language/Functions/Analog IO/analogWrite.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index f6fbcd560..d6337046a 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -26,10 +26,10 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C | UNO (R3 and earlier), Nano, Mini | 3, 5, 6, 9, 10, 11 | 490 Hz (pins 5 and 6: 980 Hz) | UNO R4 (Minima, WiFi) +*+ | 3, 5, 6, 9, 10, 11 | 490 Hz | Mega | 2 - 13, 44 - 46 | 490 Hz (pins 4 and 13: 980 Hz) -| GIGA R1** | 2 - 13 | 500 Hz +| GIGA R1 +**+ | 2 - 13 | 500 Hz | Leonardo, Micro, Yún | 3, 5, 6, 9, 10, 11, 13 | 490 Hz (pins 3 and 11: 980 Hz) | UNO WiFi Rev2, Nano Every | 3, 5, 6, 9, 10 | 976 Hz -| MKR boards +*+ | 0 - 8, 10, A3, A4 | 732 Hz +| MKR boards +*+ | 0 - 8, 10, A3, A4 | 732 Hz | MKR1000 WiFi +**+ | 0 - 8, 10, 11, A3, A4 | 732 Hz | Zero +**+ | 3 - 13, A0, A1 | 732 Hz | Nano 33 IoT +**+ | 2, 3, 5, 6, 9 - 12, A2, A3, A5 | 732 Hz From b130c36981ce3cbaecde4e8e564a32d84bc9eb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Hyl=C3=A9n?= Date: Thu, 16 Nov 2023 14:02:08 +0100 Subject: [PATCH 130/184] Update analogRead.adoc --- Language/Functions/Analog IO/analogRead.adoc | 24 ++++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Language/Functions/Analog IO/analogRead.adoc b/Language/Functions/Analog IO/analogRead.adoc index 929b1cc8a..fab0ccb76 100644 --- a/Language/Functions/Analog IO/analogRead.adoc +++ b/Language/Functions/Analog IO/analogRead.adoc @@ -20,19 +20,23 @@ On ATmega based boards (UNO, Nano, Mini, Mega), it takes about 100 microseconds [options="header"] |=================================================== -|Board |Operating voltage |Usable pins |Max resolution -|Uno |5 Volts |A0 to A5 |10 bits -|Mini, Nano |5 Volts |A0 to A7 |10 bits -|Mega, Mega2560, MegaADK |5 Volts |A0 to A14 |10 bits -|Micro |5 Volts |A0 to A11* |10 bits -|Leonardo |5 Volts |A0 to A11* |10 bits -|Zero |3.3 Volts |A0 to A5 |12 bits** -|Due |3.3 Volts |A0 to A11 |12 bits** -|MKR Family boards |3.3 Volts |A0 to A6 |12 bits** +|Board |Operating voltage |Usable pins |Max resolution +|UNO R3 |5 Volts |A0 to A5 |10 bits +|UNO R4 (Minima, WiFi) |5 Volts |A0 to A5 |14 bits** +|Mini |5 Volts |A0 to A7 |10 bits +|Nano, Nano Every |5 Volts |A0 to A7 |10 bits +|Nano 33 (IoT, BLE, RP2040, ESP32)|3.3 Volts |A0 to A7 |12 bits** +|Mega, Mega2560, MegaADK |5 Volts |A0 to A14 |10 bits +|Micro |5 Volts |A0 to A11* |10 bits +|Leonardo |5 Volts |A0 to A11* |10 bits +|Zero |3.3 Volts |A0 to A5 |12 bits** +|Due |3.3 Volts |A0 to A11 |12 bits** +|GIGA R1 |3.3 Volts |A0 to A11 |16 bits** +|MKR Family boards |3.3 Volts |A0 to A6 |12 bits** |=================================================== *A0 through A5 are labelled on the board, A6 through A11 are respectively available on pins 4, 6, 8, 9, 10, and 12 + -**The default `analogRead()` resolution for these boards is 10 bits, for compatibility. You need to use link:../../zero-due-mkr-family/analogreadresolution[analogReadResolution()] to change it to 12 bits. +**The default `analogRead()` resolution for these boards is 10 bits, for compatibility. You need to use link:../../zero-due-mkr-family/analogreadresolution[analogReadResolution()] to change it to a higher resolution. [%hardbreaks] From 03bedb21121b173ab21c738d14ce8d3d47dd25f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Hyl=C3=A9n?= Date: Thu, 16 Nov 2023 14:07:22 +0100 Subject: [PATCH 131/184] Update analogRead.adoc --- Language/Functions/Analog IO/analogRead.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogRead.adoc b/Language/Functions/Analog IO/analogRead.adoc index fab0ccb76..8eac217a5 100644 --- a/Language/Functions/Analog IO/analogRead.adoc +++ b/Language/Functions/Analog IO/analogRead.adoc @@ -47,7 +47,7 @@ On ATmega based boards (UNO, Nano, Mini, Mega), it takes about 100 microseconds [float] === Parameters -`pin`: the name of the analog input pin to read from (A0 to A5 on most boards, A0 to A6 on MKR boards, A0 to A7 on the Mini and Nano, A0 to A15 on the Mega). +`pin`: the name of the analog input pin to read from. [float] From 66968943c9062fde6264e87626156a52cc5fb11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:16:35 +0100 Subject: [PATCH 132/184] bitRead & bitWrite Improvements Adds more information to bitWrite, and a code example for how to use bitRead. --- .../Functions/Bits and Bytes/bitRead.adoc | 50 ++++++++++++++++++- .../Functions/Bits and Bytes/bitWrite.adoc | 2 +- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Bits and Bytes/bitRead.adoc b/Language/Functions/Bits and Bytes/bitRead.adoc index b6c324c15..4c4cb9346 100644 --- a/Language/Functions/Bits and Bytes/bitRead.adoc +++ b/Language/Functions/Bits and Bytes/bitRead.adoc @@ -17,7 +17,7 @@ subCategories: [ "Bits and Bytes" ] [float] === Description -Reads a bit of a number. +Reads a bit of a variable, e.g. `bool`, `int`. Note that `float` & `double` are not supported. You can read the bit of variables up to an `unsigned long long` (64 bits / 8 bytes). [%hardbreaks] @@ -36,6 +36,54 @@ Reads a bit of a number. === Returns The value of the bit (0 or 1). +=== Example Code + +This example code demonstrates how to read two variables, one increasing counter, one decreasing counter, and print out both the binary and decimal values of the variables. + +The `readBit()` function loops through each bit of the variable (starting from the rightmost bit), and prints it out. + +[source,arduino] +---- +long negative_var = -0; // +unsigned long long positive_var = 0; + +//predefined sizes when looping through bits +//e.g. long_size is 32 bit (which is 0-31). Therefore, we subtract "1". +const int bool_size = (1 - 1); +const int int_size = (8 - 1); +const int long_size = (32 - 1); + +void setup() { + Serial.begin(9600); +} + +void loop() { + //run readBit function, passing the pos/neg variables + readBit("Positive ", positive_var); + readBit("Negative ", negative_var); + Serial.println(); + + //increase and decrease the variables + negative_var--; + positive_var++; + + delay(1000); +} + +/*this function takes a variable, prints it out bit by bit (starting from the right) +then prints the decimal number for comparison.*/ +void readBit(String direction, long counter) { + Serial.print(direction + "Binary Number: "); + //loop through each bit + for (int b = long_size; b >= 0; b--) { + byte bit = bitRead(counter, b); + Serial.print(bit); + } + Serial.print(" Decimal Number: "); + Serial.println(counter); +} +---- + -- // OVERVIEW SECTION ENDS diff --git a/Language/Functions/Bits and Bytes/bitWrite.adoc b/Language/Functions/Bits and Bytes/bitWrite.adoc index b12982ed5..687fc3dcc 100644 --- a/Language/Functions/Bits and Bytes/bitWrite.adoc +++ b/Language/Functions/Bits and Bytes/bitWrite.adoc @@ -17,7 +17,7 @@ subCategories: [ "Bits and Bytes" ] [float] === Description -Writes a bit of a numeric variable. +Writes to a bit of a variable, e.g. `bool`, `int`, `long`. Note that `float` & `double` are not supported. You can read the bit of variables up to an `unsigned long` (32 bits / 8 bytes). [%hardbreaks] From b9ee540a0912715a18684da4601f07affc4df999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:19:52 +0100 Subject: [PATCH 133/184] Update bitWrite.adoc --- Language/Functions/Bits and Bytes/bitWrite.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Bits and Bytes/bitWrite.adoc b/Language/Functions/Bits and Bytes/bitWrite.adoc index 687fc3dcc..82b4d6a55 100644 --- a/Language/Functions/Bits and Bytes/bitWrite.adoc +++ b/Language/Functions/Bits and Bytes/bitWrite.adoc @@ -17,7 +17,7 @@ subCategories: [ "Bits and Bytes" ] [float] === Description -Writes to a bit of a variable, e.g. `bool`, `int`, `long`. Note that `float` & `double` are not supported. You can read the bit of variables up to an `unsigned long` (32 bits / 8 bytes). +Writes to a bit of a variable, e.g. `bool`, `int`, `long`. Note that `float` & `double` are not supported. You can write to a bit of variables up to an `unsigned long` (32 bits / 8 bytes). [%hardbreaks] From ed570d24fc46b02e5039752384668d2a8884b9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Hyl=C3=A9n?= Date: Fri, 17 Nov 2023 11:28:59 +0100 Subject: [PATCH 134/184] Add Renesas analogReference --- Language/Functions/Analog IO/analogReference.adoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Language/Functions/Analog IO/analogReference.adoc b/Language/Functions/Analog IO/analogReference.adoc index 8b463de9d..0e44b5881 100644 --- a/Language/Functions/Analog IO/analogReference.adoc +++ b/Language/Functions/Analog IO/analogReference.adoc @@ -27,6 +27,15 @@ Arduino AVR Boards (Uno, Mega, Leonardo, etc.) * INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only) * EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference. +Arduino Renesas Boards (UNO R4, Portenta C33) + +* AR_DEFAULT: the default analog reference of 5 volts. +* AR_INTERNAL: A built-in reference, equal to 1.5 Volts on the RA4M1 of the UNO R4 +* AR_INTERNAL_1_5V: A built-in reference, equal to 1.5 V on the R7FA6M5 of the Portenta C33 +* AR_INTERNAL_2_0V: A built-in reference, equal to 2.0 V on the R7FA6M5 of the Portenta C33 +* AR_INTERNAL_2_5V: A built-in reference, equal to 2.5 V on the R7FA6M5 of the Portenta C33 +* AR_EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference. + Arduino SAMD Boards (Zero, etc.) * AR_DEFAULT: the default analog reference of 3.3V From d75e087e74f5c216387a6d645604a5fa01dc40c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:54:09 +0100 Subject: [PATCH 135/184] Update attachInterrupt.adoc --- .../External Interrupts/attachInterrupt.adoc | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index 76286550e..516039edd 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -19,21 +19,21 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you [options="header"] |=================================================== -|Board |Digital Pins Usable For Interrupts -|Uno, Nano, Mini, other 328-based |2, 3 -|UNO R4 Minima, UNO R4 WiFi |2, 3 -|Uno WiFi Rev.2, Nano Every |all digital pins -|Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 (*pins 20 & 21* are not available to use for interrupts while they are used for I2C communication; they also have external pull-ups that cannot be disabled) -|Micro, Leonardo, other 32u4-based |0, 1, 2, 3, 7 -|Zero |all digital pins, except 4 -|MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2 -|Nano 33 IoT |2, 3, 9, 10, 11, 13, A1, A5, A7 -|Nano 33 BLE, Nano 33 BLE Sense |all pins -|Nano RP2040 Connect |all pins except A6/A7 -|Nano ESP32 |all pins -|GIGA R1 WiFi |all pins -|Due |all digital pins -|101 |all digital pins (Only pins 2, 5, 7, 8, 10, 11, 12, 13 work with *CHANGE*) +|Board |Digital Pins Usable For Interrupts| Note +|Uno R3, Nano, Mini, other 328-based |2, 3| +|UNO R4 Minima, UNO R4 WiFi |2, 3| +|Uno WiFi Rev.2, Nano Every |All digital pins| +|Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 |(*pins 20 & 21* are not available to use for interrupts while they are used for I2C communication; they also have external pull-ups that cannot be disabled) +|Micro, Leonardo, other 32u4-based |0, 1, 2, 3, 7| +|Zero |0-3, 5-13, A0-A5| Pin 4 cannot be used as an interrupt. +|MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2| +|Nano 33 IoT |2, 3, 9, 10, 11, 13, A1, A5, A7| +|Nano 33 BLE, Nano 33 BLE Sense |all pins| +|Nano RP2040 Connect |0-13, A0-A5| +|Nano ESP32 |all pins| +|GIGA R1 WiFi |all pins| +|Due |all digital pins| +|101 |all digital pins | (Only pins 2, 5, 7, 8, 10, 11, 12, 13 work with *CHANGE*)) |=================================================== [%hardbreaks] From 231d7ccbc16e1906ce245dd9ac27f7c40bd60620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:22:08 +0100 Subject: [PATCH 136/184] Update attachInterrupt.adoc --- Language/Functions/External Interrupts/attachInterrupt.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index 516039edd..f334b11a2 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -20,7 +20,7 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you [options="header"] |=================================================== |Board |Digital Pins Usable For Interrupts| Note -|Uno R3, Nano, Mini, other 328-based |2, 3| +|Uno Rev3, Nano, Mini, other 328-based |2, 3| |UNO R4 Minima, UNO R4 WiFi |2, 3| |Uno WiFi Rev.2, Nano Every |All digital pins| |Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 |(*pins 20 & 21* are not available to use for interrupts while they are used for I2C communication; they also have external pull-ups that cannot be disabled) @@ -28,7 +28,7 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you |Zero |0-3, 5-13, A0-A5| Pin 4 cannot be used as an interrupt. |MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2| |Nano 33 IoT |2, 3, 9, 10, 11, 13, A1, A5, A7| -|Nano 33 BLE, Nano 33 BLE Sense |all pins| +|Nano 33 BLE, Nano 33 BLE Sense (rev 1 & 2) |all pins| |Nano RP2040 Connect |0-13, A0-A5| |Nano ESP32 |all pins| |GIGA R1 WiFi |all pins| From 99922dbda68ee6cad7d8ce2b5de677c1d7ea3afc Mon Sep 17 00:00:00 2001 From: Hannes Siebeneicher Date: Mon, 20 Nov 2023 10:28:38 +0100 Subject: [PATCH 137/184] Add compatible hardware --- Language/Functions/USB/Keyboard.adoc | 25 +++++++++++++++++++++++++ Language/Functions/USB/Mouse.adoc | 24 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/Language/Functions/USB/Keyboard.adoc b/Language/Functions/USB/Keyboard.adoc index 20a1ac7df..e306febbf 100644 --- a/Language/Functions/USB/Keyboard.adoc +++ b/Language/Functions/USB/Keyboard.adoc @@ -24,6 +24,31 @@ The library supports the use of modifier keys. Modifier keys change the behavior -- // OVERVIEW SECTION ENDS +[float] +=== Compatible Hardware +HID is supported on the following boards: +[options="header"] +|========================================================= +| Board | Pins +| link:https://docs.arduino.cc/hardware/leonardo[Leonardo] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/micro[Micro] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/due[Due] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/zero[Zero] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/uno-r4-minima[UNO R4 Minima] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/uno-r4-wifi[UNO R4 WiFi] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/giga-r1[Giga R1] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/nano-esp32[Nano ESP32] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-1000-wifi[Nano ESP32] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-fox-1200[MKR FOX 1200] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-gsm-1400[MKR GSM 1400] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-nb-1500[MKR NB 1500] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-vidor-4000[MKR Vidor 4000] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-wan-1300[MKR WAN 1300] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-wan-1310[MKR WAN 1310] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-wifi-1010[MKR WiFi 1010] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-zero[MKR Zero] | Digital / Analog Pins +|========================================================= + [float] === Notes and Warnings These core libraries allow the 32u4 and SAMD based boards (Leonardo, Esplora, Zero, Due and MKR Family) to appear as a native Mouse and/or Keyboard to a connected computer. diff --git a/Language/Functions/USB/Mouse.adoc b/Language/Functions/USB/Mouse.adoc index adab1e421..cf4fc42fb 100644 --- a/Language/Functions/USB/Mouse.adoc +++ b/Language/Functions/USB/Mouse.adoc @@ -23,6 +23,30 @@ The mouse functions enable 32u4 or SAMD micro based boards to control cursor mov -- // OVERVIEW SECTION ENDS +[float] +=== Compatible Hardware +HID is supported on the following boards: +[options="header"] +|========================================================= +| Board | Pins +| link:https://docs.arduino.cc/hardware/leonardo[Leonardo] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/micro[Micro] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/due[Due] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/zero[Zero] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/uno-r4-minima[UNO R4 Minima] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/uno-r4-wifi[UNO R4 WiFi] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/giga-r1[Giga R1] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/nano-esp32[Nano ESP32] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-1000-wifi[Nano ESP32] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-fox-1200[MKR FOX 1200] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-gsm-1400[MKR GSM 1400] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-nb-1500[MKR NB 1500] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-vidor-4000[MKR Vidor 4000] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-wan-1300[MKR WAN 1300] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-wan-1310[MKR WAN 1310] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-wifi-1010[MKR WiFi 1010] | Digital / Analog Pins +| link:https://docs.arduino.cc/hardware/mkr-zero[MKR Zero] | Digital / Analog Pins +|========================================================= [float] === Notes and Warnings From 7a3331a5bbe48ec5650c7041312437cdfc506a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:41:22 +0100 Subject: [PATCH 138/184] Minor changes --- .../External Interrupts/attachInterrupt.adoc | 28 +++++++++---------- .../External Interrupts/detachInterrupt.adoc | 6 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index f334b11a2..eb6e04f0f 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -19,21 +19,21 @@ The first parameter to `attachInterrupt()` is an interrupt number. Normally you [options="header"] |=================================================== -|Board |Digital Pins Usable For Interrupts| Note -|Uno Rev3, Nano, Mini, other 328-based |2, 3| -|UNO R4 Minima, UNO R4 WiFi |2, 3| -|Uno WiFi Rev.2, Nano Every |All digital pins| -|Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 |(*pins 20 & 21* are not available to use for interrupts while they are used for I2C communication; they also have external pull-ups that cannot be disabled) -|Micro, Leonardo, other 32u4-based |0, 1, 2, 3, 7| -|Zero |0-3, 5-13, A0-A5| Pin 4 cannot be used as an interrupt. -|MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2| -|Nano 33 IoT |2, 3, 9, 10, 11, 13, A1, A5, A7| +|Board |Digital Pins Usable For Interrupts| Notes +|Uno Rev3, Nano, Mini, other 328-based |2, 3| +|UNO R4 Minima, UNO R4 WiFi |2, 3| +|Uno WiFi Rev2, Nano Every |All digital pins| +|Mega, Mega2560, MegaADK |2, 3, 18, 19, 20, 21 |(*pins 20 & 21* are not available to use for interrupts while they are used for I2C communication; they also have external pull-ups that cannot be disabled) +|Micro, Leonardo |0, 1, 2, 3, 7| +|Zero |0-3, 5-13, A0-A5| Pin 4 cannot be used as an interrupt. +|MKR Family boards |0, 1, 4, 5, 6, 7, 8, 9, A1, A2| +|Nano 33 IoT |2, 3, 9, 10, 11, 13, A1, A5, A7| |Nano 33 BLE, Nano 33 BLE Sense (rev 1 & 2) |all pins| -|Nano RP2040 Connect |0-13, A0-A5| -|Nano ESP32 |all pins| -|GIGA R1 WiFi |all pins| -|Due |all digital pins| -|101 |all digital pins | (Only pins 2, 5, 7, 8, 10, 11, 12, 13 work with *CHANGE*)) +|Nano RP2040 Connect |0-13, A0-A5| +|Nano ESP32 |all pins| +|GIGA R1 WiFi |all pins| +|Due |all digital pins| +|101 |all digital pins | (Only pins 2, 5, 7, 8, 10, 11, 12, 13 work with *CHANGE*)) |=================================================== [%hardbreaks] diff --git a/Language/Functions/External Interrupts/detachInterrupt.adoc b/Language/Functions/External Interrupts/detachInterrupt.adoc index f9e7cc395..84fa30978 100644 --- a/Language/Functions/External Interrupts/detachInterrupt.adoc +++ b/Language/Functions/External Interrupts/detachInterrupt.adoc @@ -23,9 +23,9 @@ Turns off the given interrupt. [float] === Syntax -`detachInterrupt(digitalPinToInterrupt(pin))` (recommended) + -`detachInterrupt(interrupt)` (not recommended) + -`detachInterrupt(pin)` (Not recommended. Additionally, this syntax only works on Arduino SAMD Boards, Uno WiFi Rev2, Due, and 101.) +- `detachInterrupt(digitalPinToInterrupt(pin))` (recommended) + +- `detachInterrupt(interrupt)` (not recommended) + +- `detachInterrupt(pin)` (Not recommended. Additionally, this only works on a specific set of boards.) [float] From 3e7788827416776a62a62bfc6acf12fdcda6b5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:45:50 +0100 Subject: [PATCH 139/184] Update attachInterrupt.adoc --- Language/Functions/External Interrupts/attachInterrupt.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/External Interrupts/attachInterrupt.adoc b/Language/Functions/External Interrupts/attachInterrupt.adoc index eb6e04f0f..05fa3b70c 100644 --- a/Language/Functions/External Interrupts/attachInterrupt.adoc +++ b/Language/Functions/External Interrupts/attachInterrupt.adoc @@ -137,8 +137,8 @@ Note that in the table below, the interrupt numbers refer to the number to be pa |Mega2560 | 2 | 3 | 21 | 20 | 19 | 18 |32u4 based (e.g Leonardo, Micro) | 3 | 2 | 0 | 1 | 7 | |=================================================== -For Uno WiFiRev.2, Due, Zero, MKR Family and 101 boards the *interrupt number = pin number*. +For Uno WiFi Rev2, Due, Zero, MKR Family and 101 boards the *interrupt number = pin number*. -- // HOW TO USE SECTION ENDS From 92f47b0b8a336865ea0951f526934d0d1536f841 Mon Sep 17 00:00:00 2001 From: Hannes Siebeneicher Date: Mon, 20 Nov 2023 10:58:54 +0100 Subject: [PATCH 140/184] update tables --- Language/Functions/USB/Keyboard.adoc | 33 +++++++++++----------------- Language/Functions/USB/Mouse.adoc | 33 +++++++++++----------------- 2 files changed, 26 insertions(+), 40 deletions(-) diff --git a/Language/Functions/USB/Keyboard.adoc b/Language/Functions/USB/Keyboard.adoc index e306febbf..f1d9c565a 100644 --- a/Language/Functions/USB/Keyboard.adoc +++ b/Language/Functions/USB/Keyboard.adoc @@ -28,26 +28,19 @@ The library supports the use of modifier keys. Modifier keys change the behavior === Compatible Hardware HID is supported on the following boards: [options="header"] -|========================================================= -| Board | Pins -| link:https://docs.arduino.cc/hardware/leonardo[Leonardo] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/micro[Micro] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/due[Due] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/zero[Zero] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/uno-r4-minima[UNO R4 Minima] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/uno-r4-wifi[UNO R4 WiFi] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/giga-r1[Giga R1] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/nano-esp32[Nano ESP32] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-1000-wifi[Nano ESP32] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-fox-1200[MKR FOX 1200] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-gsm-1400[MKR GSM 1400] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-nb-1500[MKR NB 1500] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-vidor-4000[MKR Vidor 4000] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-wan-1300[MKR WAN 1300] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-wan-1310[MKR WAN 1310] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-wifi-1010[MKR WiFi 1010] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-zero[MKR Zero] | Digital / Analog Pins -|========================================================= +|================================================================================================= +| Board | Supported Pins +| link:https://docs.arduino.cc/hardware/leonardo[Leonardo] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/micro[Micro] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/due[Due] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/zero[Zero] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/uno-r4-minima[UNO R4 Minima] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/uno-r4-wifi[UNO R4 WiFi] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/giga-r1[Giga R1] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/nano-esp32[Nano ESP32] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/mkr-1000-wifi[Nano ESP32] | All digital & analog pins +| link:https://docs.arduino.cc/#mkr-family[MKR Family] | All digital & analog pins +|================================================================================================= [float] === Notes and Warnings diff --git a/Language/Functions/USB/Mouse.adoc b/Language/Functions/USB/Mouse.adoc index cf4fc42fb..c4c8e3865 100644 --- a/Language/Functions/USB/Mouse.adoc +++ b/Language/Functions/USB/Mouse.adoc @@ -27,26 +27,19 @@ The mouse functions enable 32u4 or SAMD micro based boards to control cursor mov === Compatible Hardware HID is supported on the following boards: [options="header"] -|========================================================= -| Board | Pins -| link:https://docs.arduino.cc/hardware/leonardo[Leonardo] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/micro[Micro] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/due[Due] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/zero[Zero] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/uno-r4-minima[UNO R4 Minima] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/uno-r4-wifi[UNO R4 WiFi] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/giga-r1[Giga R1] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/nano-esp32[Nano ESP32] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-1000-wifi[Nano ESP32] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-fox-1200[MKR FOX 1200] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-gsm-1400[MKR GSM 1400] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-nb-1500[MKR NB 1500] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-vidor-4000[MKR Vidor 4000] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-wan-1300[MKR WAN 1300] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-wan-1310[MKR WAN 1310] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-wifi-1010[MKR WiFi 1010] | Digital / Analog Pins -| link:https://docs.arduino.cc/hardware/mkr-zero[MKR Zero] | Digital / Analog Pins -|========================================================= +|================================================================================================= +| Board | Supported Pins +| link:https://docs.arduino.cc/hardware/leonardo[Leonardo] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/micro[Micro] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/due[Due] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/zero[Zero] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/uno-r4-minima[UNO R4 Minima] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/uno-r4-wifi[UNO R4 WiFi] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/giga-r1[Giga R1] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/nano-esp32[Nano ESP32] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/mkr-1000-wifi[Nano ESP32] | All digital & analog pins +| link:https://docs.arduino.cc/#mkr-family[MKR Family] | All digital & analog pins +|================================================================================================= [float] === Notes and Warnings From 891e174b6d1548a958c85aec5f14c2ff34eac35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:51:50 +0100 Subject: [PATCH 141/184] Update Switch Case Remove limitation that only char/int can be used (any integer is allowed) --- Language/Structure/Control Structure/switchCase.adoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Language/Structure/Control Structure/switchCase.adoc b/Language/Structure/Control Structure/switchCase.adoc index faa4a60a7..a51a4319b 100644 --- a/Language/Structure/Control Structure/switchCase.adoc +++ b/Language/Structure/Control Structure/switchCase.adoc @@ -44,9 +44,10 @@ switch (var) { [float] === Parameters -`var`: a variable whose value to compare with various cases. Allowed data types: `int`, `char`. + -`label1`, `label2`: constants. Allowed data types: `int`, `char`. +`var`: an *integer* variable whose value to compare with various cases. Any integer data type is allowed*, such as `byte`, `char`, `int`, `long`. +`label1`, `label2`: constants. Any integer data type here is also allowed. +*You can also use the `bool` data type when you just two switch cases. [float] === Returns From 8a2d16171a333dd92fc3a8e56bfc81b8205aefa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:53:48 +0100 Subject: [PATCH 142/184] Update switchCase.adoc --- Language/Structure/Control Structure/switchCase.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Language/Structure/Control Structure/switchCase.adoc b/Language/Structure/Control Structure/switchCase.adoc index a51a4319b..e608c23d2 100644 --- a/Language/Structure/Control Structure/switchCase.adoc +++ b/Language/Structure/Control Structure/switchCase.adoc @@ -49,6 +49,8 @@ switch (var) { *You can also use the `bool` data type when you just two switch cases. +Note that you can also negative values as input. + [float] === Returns Nothing From d044e05bf72ce3f9148b93a9789fc14f7efaa040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 20 Nov 2023 16:33:37 +0100 Subject: [PATCH 143/184] DigitalPinToInterrupt docs added The digitalPinToInterrupt is available in all architectures and was missing from the lang ref. --- .../digitalPinToInterrupt.adoc | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Language/Functions/External Interrupts/digitalPinToInterrupt.adoc diff --git a/Language/Functions/External Interrupts/digitalPinToInterrupt.adoc b/Language/Functions/External Interrupts/digitalPinToInterrupt.adoc new file mode 100644 index 000000000..a5077725f --- /dev/null +++ b/Language/Functions/External Interrupts/digitalPinToInterrupt.adoc @@ -0,0 +1,92 @@ +--- +title: digitalPinToInterrupt() +categories: [ "Functions" ] +subCategories: [ "External Interrupts" ] +--- + + + + + += digitalPinToInterrupt() + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +The `digitalPinToInterrupt()` function takes a pin as an argument, and returns the same pin *if* it can be used as an interrupt. For example, `digitalPinToInterrupt(4)` on an Arduino UNO will not work, as interrupts are only supported on pins 2,3. + +See link:../../external-interrupts/attachinterrupt[attachInterrupt()] for a full list of supported interrupt pins on all boards. + +[%hardbreaks] + + +[float] +=== Syntax +`digitalPinToInterrupt(pin)` + + +[float] +=== Parameters +- `pin` - the pin we want to use for an interrupt. + + +[float] +=== Returns +- The pin to interrupt (e.g. `2`)+ +- If pin is not available for interrupt, returns `-1`. + +-- +// OVERVIEW SECTION ENDS + + + + +// HOW TO USE SECTION STARTS +[#howtouse] +-- + +[float] +=== Example Code +// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄ +This example checks if a pin can be used as an interrupt. + +[source,arduino] +---- +int pin = 2; + +void setup() { + Serial.begin(9600); + int checkPin = digitalPinToInterrupt(pin); + + if (checkPin == -1) { + Serial.println("Not a valid interrupt pin!"); + } else { + Serial.println("Valid interrupt pin."); + } +} + +void loop() { +} +---- + +-- +// HOW TO USE SECTION ENDS + + +// SEE ALSO SECTION +[#see_also] +-- + +[float] +=== See also + +[role="language"] +* #LANGUAGE# link:../../external-interrupts/attachinterrupt[attachInterrupts()] +* #LANGUAGE# link:../../external-interrupts/detachinterrupt[detachInterrupts()] + +-- +// SEE ALSO SECTION ENDS From 65a628db16244ff8981e20cb5110ec9d3fefd16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 20 Nov 2023 16:44:26 +0100 Subject: [PATCH 144/184] Update reserve.adoc --- Language/Variables/Data Types/String/Functions/reserve.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/String/Functions/reserve.adoc b/Language/Variables/Data Types/String/Functions/reserve.adoc index 10d76d6ec..de64fdd0d 100644 --- a/Language/Variables/Data Types/String/Functions/reserve.adoc +++ b/Language/Variables/Data Types/String/Functions/reserve.adoc @@ -35,7 +35,7 @@ The String reserve() function allows you to allocate a buffer in memory for mani [float] === Returns -Nothing +`1` on success, `0` on failure. -- // OVERVIEW SECTION ENDS From 5f9641561e1c2c844765ed3dcf55d19dcc9d688a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 21 Nov 2023 14:20:56 +0100 Subject: [PATCH 145/184] Update PROGMEM.adoc --- Language/Variables/Utilities/PROGMEM.adoc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Language/Variables/Utilities/PROGMEM.adoc b/Language/Variables/Utilities/PROGMEM.adoc index 2006bc5ff..e7c4dbc1c 100644 --- a/Language/Variables/Utilities/PROGMEM.adoc +++ b/Language/Variables/Utilities/PROGMEM.adoc @@ -17,17 +17,22 @@ subCategories: [ "Utilities" ] [float] === Description + Keep constant data in flash (program) memory only, instead of copying it to SRAM when the program starts. There's a description of the various https://www.arduino.cc/en/Tutorial/Foundations/Memory[types of memory] available on an Arduino board. The `PROGMEM` keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "keep this information in flash memory only", instead of copying it to SRAM at start up, like it would normally do. -PROGMEM is part of the link:http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h] library. It is included automatically in modern versions of the IDE. However, if you are using an IDE version below 1.0 (2011), you'll first need to include the library at the top of your sketch, like this: - -`#include ` +PROGMEM is part of the link:http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h] library. It is included automatically in modern versions of the IDE. While `PROGMEM` could be used on a single variable, it is really only worth the fuss if you have a larger block of data that needs to be stored, which is usually easiest in an array, (or another C++ data structure beyond our present discussion). Using `PROGMEM` is a two-step procedure. Once a variable has been defined with `PROGMEM`, it cannot be read like a regular SRAM-based variable: you have to read it using specific functions, also defined in link:http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h]. + +==== Important Note! + +`PROGMEM` is useful _only_ when working with AVR boards (Uno Rev3, Leonardo etc.). Newer boards (Due, MKR WiFi 1010, GIGA R1 WiFi etc.), automatically uses the program space when a variable is declared as a `const`. However, for retro compatibility, `PROGMEM` can still be used with newer boards. This implementation currently lives link:https://github.com/arduino/ArduinoCore-API/blob/master/api/deprecated-avr-comp/avr/pgmspace.h[here]. + + [%hardbreaks] From f06bbe07dd2ea79bcc155db005f3332476bedd9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 21 Nov 2023 14:32:20 +0100 Subject: [PATCH 146/184] Remove old version mentions Mentions referring to versions below 1.0 was removed. These are likely 15+ years old, as we are now in version 2.3.x of the IDE --- Language/Functions/Communication/Serial/flush.adoc | 2 +- Language/Functions/Communication/Serial/ifSerial.adoc | 1 - Language/Functions/Communication/Serial/write.adoc | 2 +- Language/Functions/Communication/Wire.adoc | 4 ++-- Language/Functions/Communication/Wire/endTransmission.adoc | 2 +- Language/Functions/Communication/Wire/requestFrom.adoc | 2 +- Language/Functions/Digital IO/pinMode.adoc | 2 +- Language/Functions/Time/delayMicroseconds.adoc | 2 -- .../Variables/Data Types/String/Functions/toLowerCase.adoc | 2 +- .../Variables/Data Types/String/Functions/toUpperCase.adoc | 2 +- Language/Variables/Data Types/String/Functions/trim.adoc | 2 +- Language/Variables/Data Types/string.adoc | 2 +- 12 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Language/Functions/Communication/Serial/flush.adoc b/Language/Functions/Communication/Serial/flush.adoc index b4cdcac72..03a0b6819 100644 --- a/Language/Functions/Communication/Serial/flush.adoc +++ b/Language/Functions/Communication/Serial/flush.adoc @@ -14,7 +14,7 @@ title: Serial.flush() [float] === Description -Waits for the transmission of outgoing serial data to complete. (Prior to Arduino 1.0, this instead removed any buffered incoming serial data.) +Waits for the transmission of outgoing serial data to complete. `flush()` inherits from the link:../../stream/streamflush[Stream] utility class. [%hardbreaks] diff --git a/Language/Functions/Communication/Serial/ifSerial.adoc b/Language/Functions/Communication/Serial/ifSerial.adoc index 42b3b48d7..a41c1ec88 100644 --- a/Language/Functions/Communication/Serial/ifSerial.adoc +++ b/Language/Functions/Communication/Serial/ifSerial.adoc @@ -18,7 +18,6 @@ Indicates if the specified Serial port is ready. On the boards with native USB, `if (Serial)` (or `if(SerialUSB)` on the Due) indicates whether or not the USB CDC serial connection is open. For all other boards, and the non-USB CDC ports, this will always return true. -This was introduced in Arduino IDE 1.0.1. [%hardbreaks] diff --git a/Language/Functions/Communication/Serial/write.adoc b/Language/Functions/Communication/Serial/write.adoc index aa2117dfb..00f0bdc66 100644 --- a/Language/Functions/Communication/Serial/write.adoc +++ b/Language/Functions/Communication/Serial/write.adoc @@ -65,7 +65,7 @@ void loop() { [float] === Notes and Warnings -As of Arduino IDE 1.0, serial transmission is asynchronous. If there is enough empty space in the transmit buffer, `Serial.write()` will return before any characters are transmitted over serial. If the transmit buffer is full then `Serial.write()` will block until there is enough space in the buffer. To avoid blocking calls to `Serial.write()`, you can first check the amount of free space in the transmit buffer using link:../availableforwrite[availableForWrite()]. +Serial transmission is asynchronous. If there is enough empty space in the transmit buffer, `Serial.write()` will return before any characters are transmitted over serial. If the transmit buffer is full then `Serial.write()` will block until there is enough space in the buffer. To avoid blocking calls to `Serial.write()`, you can first check the amount of free space in the transmit buffer using link:../availableforwrite[availableForWrite()]. -- // HOW TO USE SECTION ENDS diff --git a/Language/Functions/Communication/Wire.adoc b/Language/Functions/Communication/Wire.adoc index 8607a3e40..26c3e6df2 100644 --- a/Language/Functions/Communication/Wire.adoc +++ b/Language/Functions/Communication/Wire.adoc @@ -16,7 +16,7 @@ subCategories: [ "Communication" ] === Description -This library allows you to communicate with I2C/TWI devices. On the Arduino boards with the R3 layout (1.0 pinout), the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. The Arduino Due has two I2C/TWI interfaces SDA1 and SCL1 are near to the AREF pin and the additional one is on pins 20 and 21. +This library allows you to communicate with I2C/TWI devices. On the Arduino boards with the R3 layout, the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. The Arduino Due has two I2C/TWI interfaces SDA1 and SCL1 are near to the AREF pin and the additional one is on pins 20 and 21. As a reference the table below shows where TWI pins are located on various Arduino boards. @@ -36,7 +36,7 @@ As a reference the table below shows where TWI pins are located on various Ardui |=== -As of Arduino 1.0, the library inherits from the Stream functions, making it consistent with other read/write libraries. Because of this, `send()` and `receive()` have been replaced with `read()` and `write()`. +This library inherits from the Stream functions, making it consistent with other read/write libraries. Because of this, `send()` and `receive()` have been replaced with `read()` and `write()`. Recent versions of the Wire library can use timeouts to prevent a lockup in the face of certain problems on the bus, but this is not enabled by default (yet) in current versions. It is recommended to always enable these timeouts when using the Wire library. See the Wire.setWireTimeout function for more details. diff --git a/Language/Functions/Communication/Wire/endTransmission.adoc b/Language/Functions/Communication/Wire/endTransmission.adoc index 2040ca993..5687ed70a 100644 --- a/Language/Functions/Communication/Wire/endTransmission.adoc +++ b/Language/Functions/Communication/Wire/endTransmission.adoc @@ -10,7 +10,7 @@ title: endTransmission() [float] === Description -This function ends a transmission to a peripheral device that was begun by `beginTransmission()` and transmits the bytes that were queued by `write()`. As of Arduino 1.0.1, `endTransmission()` accepts a boolean argument changing its behavior for compatibility with certain I2C devices. If true, `endTransmission()` sends a stop message after transmission, releasing the I2C bus. If false, `endTransmission()` sends a restart message after transmission. The bus will not be released, which prevents another controller device from transmitting between messages. This allows one controller device to send multiple transmissions while in control. The default value is true. +This function ends a transmission to a peripheral device that was begun by `beginTransmission()` and transmits the bytes that were queued by `write()`. The `endTransmission()` method accepts a boolean argument changing its behavior for compatibility with certain I2C devices. If true, `endTransmission()` sends a stop message after transmission, releasing the I2C bus. If false, `endTransmission()` sends a restart message after transmission. The bus will not be released, which prevents another controller device from transmitting between messages. This allows one controller device to send multiple transmissions while in control. The default value is true. [float] === Syntax diff --git a/Language/Functions/Communication/Wire/requestFrom.adoc b/Language/Functions/Communication/Wire/requestFrom.adoc index ca9f2a441..342dc54da 100644 --- a/Language/Functions/Communication/Wire/requestFrom.adoc +++ b/Language/Functions/Communication/Wire/requestFrom.adoc @@ -11,7 +11,7 @@ title: requestFrom() [float] === Description -This function is used by the controller device to request bytes from a peripheral device. The bytes may then be retrieved with the `available()` and `read()` functions. As of Arduino 1.0.1, `requestFrom()` accepts a boolean argument changing its behavior for compatibility with certain I2C devices. If true, `requestFrom()` sends a stop message after the request, releasing the I2C bus. If false, `requestFrom()` sends a restart message after the request. The bus will not be released, which prevents another master device from requesting between messages. This allows one master device to send multiple requests while in control. The default value is true. +This function is used by the controller device to request bytes from a peripheral device. The bytes may then be retrieved with the `available()` and `read()` functions. The `requestFrom()` method accepts a boolean argument changing its behavior for compatibility with certain I2C devices. If true, `requestFrom()` sends a stop message after the request, releasing the I2C bus. If false, `requestFrom()` sends a restart message after the request. The bus will not be released, which prevents another master device from requesting between messages. This allows one master device to send multiple requests while in control. The default value is true. [float] === Syntax diff --git a/Language/Functions/Digital IO/pinMode.adoc b/Language/Functions/Digital IO/pinMode.adoc index 882e8c221..46daae777 100644 --- a/Language/Functions/Digital IO/pinMode.adoc +++ b/Language/Functions/Digital IO/pinMode.adoc @@ -19,7 +19,7 @@ subCategories: [ "Digital I/O" ] === Description Configures the specified pin to behave either as an input or an output. See the http://arduino.cc/en/Tutorial/DigitalPins[Digital Pins] page for details on the functionality of the pins. [%hardbreaks] -As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode `INPUT_PULLUP`. Additionally, the `INPUT` mode explicitly disables the internal pullups. +It is possible to enable the internal pullup resistors with the mode `INPUT_PULLUP`. Additionally, the `INPUT` mode explicitly disables the internal pullups. [%hardbreaks] diff --git a/Language/Functions/Time/delayMicroseconds.adoc b/Language/Functions/Time/delayMicroseconds.adoc index 2c5b02677..7b57914da 100644 --- a/Language/Functions/Time/delayMicroseconds.adoc +++ b/Language/Functions/Time/delayMicroseconds.adoc @@ -73,8 +73,6 @@ void loop() { === Notes and Warnings This function works very accurately in the range 3 microseconds and up to 16383. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times. Larger delay times may actually delay for an extremely brief time. -As of Arduino 0018, delayMicroseconds() no longer disables interrupts. - -- // HOW TO USE SECTION ENDS diff --git a/Language/Variables/Data Types/String/Functions/toLowerCase.adoc b/Language/Variables/Data Types/String/Functions/toLowerCase.adoc index 9fe9a2fb5..2d1ba3b57 100644 --- a/Language/Variables/Data Types/String/Functions/toLowerCase.adoc +++ b/Language/Variables/Data Types/String/Functions/toLowerCase.adoc @@ -17,7 +17,7 @@ subCategories: [ "StringObject Function" ] [float] === Description -Get a lower-case version of a String. As of 1.0, toLowerCase() modifies the String in place rather than returning a new one. +Get a lower-case version of a String. The `toLowerCase()` function modifies the String in place rather than returning a new one. [%hardbreaks] diff --git a/Language/Variables/Data Types/String/Functions/toUpperCase.adoc b/Language/Variables/Data Types/String/Functions/toUpperCase.adoc index 81ef0dd79..231dcc27c 100644 --- a/Language/Variables/Data Types/String/Functions/toUpperCase.adoc +++ b/Language/Variables/Data Types/String/Functions/toUpperCase.adoc @@ -17,7 +17,7 @@ subCategories: [ "StringObject Function" ] [float] === Description -Get an upper-case version of a String. As of 1.0, toUpperCase() modifies the String in place rather than returning a new one. +Get an upper-case version of a String. The `toUpperCase()` modifies the String in place rather than returning a new one. [%hardbreaks] diff --git a/Language/Variables/Data Types/String/Functions/trim.adoc b/Language/Variables/Data Types/String/Functions/trim.adoc index f5a3fb27d..3714c4f87 100644 --- a/Language/Variables/Data Types/String/Functions/trim.adoc +++ b/Language/Variables/Data Types/String/Functions/trim.adoc @@ -17,7 +17,7 @@ subCategories: [ "StringObject Function" ] [float] === Description -Get a version of the String with any leading and trailing whitespace removed. As of 1.0, trim() modifies the String in place rather than returning a new one. +Get a version of the String with any leading and trailing whitespace removed. The `trim()` function modifies the String in place rather than returning a new one. [%hardbreaks] diff --git a/Language/Variables/Data Types/string.adoc b/Language/Variables/Data Types/string.adoc index c19ab743e..29d4f97ad 100644 --- a/Language/Variables/Data Types/string.adoc +++ b/Language/Variables/Data Types/string.adoc @@ -12,7 +12,7 @@ subCategories: [ "Data Types" ] [float] === Description -Text strings can be represented in two ways. you can use the String data type, which is part of the core as of version 0019, or you can make a string out of an array of type char and null-terminate it. This page described the latter method. For more details on the String object, which gives you more functionality at the cost of more memory, see the link:../stringobject[String object] page. +Text strings can be represented in two ways. you can use the String data type, or you can make a string out of an array of type char and null-terminate it. This page described the latter method. For more details on the String object, which gives you more functionality at the cost of more memory, see the link:../stringobject[String object] page. [%hardbreaks] [float] From 1198f472e07ed8384e5d6e274e94a09435e7319e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:18:54 +0100 Subject: [PATCH 147/184] Update Language/Variables/Utilities/PROGMEM.adoc Co-authored-by: Edgar Bonet --- Language/Variables/Utilities/PROGMEM.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Utilities/PROGMEM.adoc b/Language/Variables/Utilities/PROGMEM.adoc index e7c4dbc1c..667135086 100644 --- a/Language/Variables/Utilities/PROGMEM.adoc +++ b/Language/Variables/Utilities/PROGMEM.adoc @@ -30,7 +30,7 @@ Using `PROGMEM` is a two-step procedure. Once a variable has been defined with ` ==== Important Note! -`PROGMEM` is useful _only_ when working with AVR boards (Uno Rev3, Leonardo etc.). Newer boards (Due, MKR WiFi 1010, GIGA R1 WiFi etc.), automatically uses the program space when a variable is declared as a `const`. However, for retro compatibility, `PROGMEM` can still be used with newer boards. This implementation currently lives link:https://github.com/arduino/ArduinoCore-API/blob/master/api/deprecated-avr-comp/avr/pgmspace.h[here]. +`PROGMEM` is useful _only_ when working with AVR boards (Uno Rev3, Leonardo etc.). Newer boards (Due, MKR WiFi 1010, GIGA R1 WiFi etc.) automatically use the program space when a variable is declared as a `const`. However, for retro compatibility, `PROGMEM` can still be used with newer boards. This implementation currently lives link:https://github.com/arduino/ArduinoCore-API/blob/master/api/deprecated-avr-comp/avr/pgmspace.h[here]. [%hardbreaks] From 7672cd6623d8bb209bef50b8a97ff14f7414377c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 22 Nov 2023 17:06:12 +0100 Subject: [PATCH 148/184] Update PROGMEM.adoc --- Language/Variables/Utilities/PROGMEM.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Utilities/PROGMEM.adoc b/Language/Variables/Utilities/PROGMEM.adoc index 667135086..0728741c6 100644 --- a/Language/Variables/Utilities/PROGMEM.adoc +++ b/Language/Variables/Utilities/PROGMEM.adoc @@ -22,7 +22,7 @@ Keep constant data in flash (program) memory only, instead of copying it to SRAM The `PROGMEM` keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "keep this information in flash memory only", instead of copying it to SRAM at start up, like it would normally do. -PROGMEM is part of the link:http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h] library. It is included automatically in modern versions of the IDE. +PROGMEM is part of the link:http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h] library. It is included automatically in the Arduino IDE. While `PROGMEM` could be used on a single variable, it is really only worth the fuss if you have a larger block of data that needs to be stored, which is usually easiest in an array, (or another C++ data structure beyond our present discussion). From e8c05b8aed71bb9cb89472af87f7b18a62102cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Mon, 27 Nov 2023 11:26:11 +0100 Subject: [PATCH 149/184] Added table --- Language/Functions/Communication/SPI.adoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index 005f765dc..d7ec8c9cd 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -27,6 +27,22 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le -- // OVERVIEW SECTION ENDS +// HOW TO USE SECTION STARTS +[#howtouse] +-- +|================================================================================================================================================ +| Boards | SPI Pins | SPI Headers | +| Leonardo, UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd, UNO R4 Minima, UNO R4 WiFi, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | +| Micro | 14(CIPO), 15(SCK), 16(COPI) | | +| Nano boards | 11(COPI), 12(CIPO), 13(SCK) | | +| MKR boards | 8(COPI), 9(SCK), 10(CIPO) | | +| Due | | 74(CIPO), 75(MOSI), 76(SCK) | +| GIGA R1 WiFi | 12(CIPO), 11(COPI), 13(SCK), 10(CS) | 89(CIPO), 90(COPI), 91(SCK) | +| Mega 2560 Rev3 | | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | +|================================================================================================================================================ + +-- +// HOW TO USE SECTION ENDS // FUNCTIONS SECTION STARTS [#functions] From f1de0ea6350a587f339ceb28bd7a7bf20af6cad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:26:57 +0100 Subject: [PATCH 150/184] revision of benjis draft --- Language/Variables/Constants/highLow.adoc | 61 ++++++++++++++++ .../Constants/inputOutputPullup.adoc | 73 +++++++++++++++++++ Language/Variables/Constants/ledbuiltin.adoc | 31 ++++++++ Language/Variables/Constants/trueFalse.adoc | 47 ++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 Language/Variables/Constants/highLow.adoc create mode 100644 Language/Variables/Constants/inputOutputPullup.adoc create mode 100644 Language/Variables/Constants/ledbuiltin.adoc create mode 100644 Language/Variables/Constants/trueFalse.adoc diff --git a/Language/Variables/Constants/highLow.adoc b/Language/Variables/Constants/highLow.adoc new file mode 100644 index 000000000..f7d84a9ae --- /dev/null +++ b/Language/Variables/Constants/highLow.adoc @@ -0,0 +1,61 @@ +--- +title: HIGH | LOW +categories: [ "Variables" ] +subCategories: [ "Constants" ] +--- + += HIGH | LOW + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +== Defining Pin Levels: HIGH and LOW +When reading or writing to a digital pin there are only two possible values a pin can take/be-set-to: `HIGH` and `LOW`. These are the same as `true` and `false`, as well as `0` and `1`. + +[float] +=== HIGH +The meaning of `HIGH` (in reference to a pin) is somewhat different depending on whether a pin is set to an `INPUT` or `OUTPUT`. When a pin is configured as an `INPUT` with `link:../../../functions/digital-io/pinmode[pinMode()]`, and read with `link:../../../functions/digital-io/digitalread[digitalRead()]`, the Arduino (ATmega) will report `HIGH` if: + + - a voltage greater than 3.0V is present at the pin (5V boards) + - a voltage greater than 2.0V is present at the pin (3.3V boards) +[%hardbreaks] + +A pin may also be configured as an INPUT with link:../../../functions/digital-io/pinmode[`pinMode()`], and subsequently made HIGH with `link:../../../functions/digital-io/digitalwrite[digitalWrite()]`. This will enable the internal 20K pullup resistors, which will _pull up_ the input pin to a `HIGH` reading unless it is pulled `LOW` by external circuitry. This can be done alternatively by passing `INPUT_PULLUP` as argument to the link:../../../functions/digital-io/pinmode[`pinMode()`] function, as explained in more detail in the section "Defining Digital Pins modes: INPUT, INPUT_PULLUP, and OUTPUT" further below. +[%hardbreaks] + +When a pin is configured to OUTPUT with link:../../../functions/digital-io/pinmode[`pinMode()`], and set to `HIGH` with link:../../../functions/digital-io/digitalwrite[`digitalWrite()`], the pin is at: + + - 5 volts (5V boards) + - 3.3 volts (3.3V boards) + +In this state it can source current, e.g. light an LED that is connected through a series resistor to ground. +[%hardbreaks] + +[float] +=== LOW + +The meaning of LOW also has a different meaning depending on whether a pin is set to INPUT or OUTPUT. When a pin is configured as an INPUT with pinMode(), and read with digitalRead(), the Arduino (ATmega) will report LOW if: + +a voltage less than 1.5V is present at the pin (5V boards) + +a voltage less than 1.0V (Approx) is present at the pin (3.3V boards) + +When a pin is configured to OUTPUT with pinMode(), and set to LOW with digitalWrite(), the pin is at 0 volts (both 5V and 3.3V boards). In this state it can sink current, e.g. light an LED that is connected through a series resistor to +5 volts (or +3.3 volts). + +-- +// OVERVIEW SECTION ENDS + + +// SEE ALSO SECTION BEGINS +[#see_also] +-- + +[float] +=== See also + +[role="language"] + +-- +// SEE ALSO SECTION ENDS \ No newline at end of file diff --git a/Language/Variables/Constants/inputOutputPullup.adoc b/Language/Variables/Constants/inputOutputPullup.adoc new file mode 100644 index 000000000..5cf653401 --- /dev/null +++ b/Language/Variables/Constants/inputOutputPullup.adoc @@ -0,0 +1,73 @@ +--- +title: INPUT | INPUT_PULLUP | OUTPUT +categories: [ "Variables" ] +subCategories: [ "Constants" ] +--- + += INPUT | INPUT_PULLUP | OUTPUT + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +== Defining Digital Pins modes: INPUT, INPUT_PULLUP, and OUTPUT +Digital pins can be used as `INPUT`, `INPUT_PULLUP`, or `OUTPUT`. Changing a pin with link:../../../functions/digital-io/pinmode[`pinMode()`] changes the electrical behavior of the pin. + +-- +// OVERVIEW SECTION ENDS + +// HOW TO USE SECTION STARTS +[#howtouse] +-- + +[float] +=== INPUT +Arduino (ATmega) pins configured as `INPUT` with link:../../../functions/digital-io/pinmode[`pinMode()`] are said to be in a _high-impedance_ state. Pins configured as `INPUT` make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 Megohms in front of the pin. This makes them useful for reading a sensor. +[%hardbreaks] + +If you have your pin configured as an `INPUT`, and are reading a switch, when the switch is in the open state the input pin will be "floating", resulting in unpredictable results. In order to assure a proper reading when the switch is open, a pull-up or pull-down resistor must be used. The purpose of this resistor is to pull the pin to a known state when the switch is open. A 10 K ohm resistor is usually chosen, as it is a low enough value to reliably prevent a floating input, and at the same time a high enough value to not draw too much current when the switch is closed. See the http://arduino.cc/en/Tutorial/DigitalReadSerial[Digital Read Serial^] tutorial for more information. +[%hardbreaks] + +If a pull-down resistor is used, the input pin will be `LOW` when the switch is open and `HIGH` when the switch is closed. +[%hardbreaks] + +If a pull-up resistor is used, the input pin will be `HIGH` when the switch is open and `LOW` when the switch is closed. +[%hardbreaks] + +[float] +=== INPUT_PULLUP +The ATmega microcontroller on the Arduino has internal pull-up resistors (resistors that connect to power internally) that you can access. If you prefer to use these instead of external pull-up resistors, you can use the `INPUT_PULLUP` argument in link:../../../functions/digital-io/pinmode[`pinMode()`]. +[%hardbreaks] + +See the http://arduino.cc/en/Tutorial/InputPullupSerial[Input Pullup Serial^] tutorial for an example of this in use. +[%hardbreaks] + +Pins configured as inputs with either `INPUT` or `INPUT_PULLUP` can be damaged or destroyed if they are connected to voltages below ground (negative voltages) or above the positive power rail (5V or 3V). +[%hardbreaks] + +[float] +=== OUTPUT +Pins configured as `OUTPUT` with link:../../../functions/digital-io/pinmode[`pinMode()`] are said to be in a _low-impedance_ state. This means that they can provide a substantial amount of current to other circuits. ATmega pins can source (provide current) or sink (absorb current) up to 40 mA (milliamps) of current to other devices/circuits. This makes them useful for powering LEDs because LEDs typically use less than 40 mA. Loads greater than 40 mA (e.g. motors) will require a transistor or other interface circuitry. +[%hardbreaks] + +Pins configured as outputs can be damaged or destroyed if they are connected to either the ground or positive power rails. +[%hardbreaks] + + +-- +// HOW TO USE SECTION ENDS + + + +// SEE ALSO SECTION BEGINS +[#see_also] +-- + +[float] +=== See also + +[role="language"] + +-- +// SEE ALSO SECTION ENDS \ No newline at end of file diff --git a/Language/Variables/Constants/ledbuiltin.adoc b/Language/Variables/Constants/ledbuiltin.adoc new file mode 100644 index 000000000..7ff780510 --- /dev/null +++ b/Language/Variables/Constants/ledbuiltin.adoc @@ -0,0 +1,31 @@ +--- +title: LED_BUILTIN +categories: [ "Variables" ] +subCategories: [ "Constants" ] +--- + += LED_BUILTIN + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +== Defining built-ins: LED_BUILTIN +Most Arduino boards have a pin connected to an on-board LED in series with a resistor. The constant `LED_BUILTIN` is the number of the pin to which the on-board LED is connected. Most boards have this LED connected to digital pin 13. + +-- +// OVERVIEW SECTION ENDS + + +// SEE ALSO SECTION BEGINS +[#see_also] +-- + +[float] +=== See also + +[role="language"] + +-- +// SEE ALSO SECTION ENDS \ No newline at end of file diff --git a/Language/Variables/Constants/trueFalse.adoc b/Language/Variables/Constants/trueFalse.adoc new file mode 100644 index 000000000..fe260f872 --- /dev/null +++ b/Language/Variables/Constants/trueFalse.adoc @@ -0,0 +1,47 @@ +--- +title: 'true | false' +categories: [ "Variables" ] +subCategories: [ "Constants" ] +--- + += true | false + +// OVERVIEW SECTION STARTS +[#overview] +-- + +There are two constants used to represent truth and falsity in the Arduino language: `true`, and `false`. + +[float] +=== true +`true` is often said to be defined as 1, which is correct, but true has a wider definition. Any integer which is non-zero is true, in a Boolean sense. So -1, 2 and -200 are all defined as true, too, in a Boolean sense. +[%hardbreaks] + +Note that the `true` and `false` constants are typed in lowercase unlike `HIGH`, `LOW`, `INPUT`, and `OUTPUT`. +[%hardbreaks] + + +[float] +=== false +`false` is the easier of the two to define. false is defined as 0 (zero). +[%hardbreaks] + +Note that the `true` and `false` constants are typed in lowercase unlike `HIGH`, `LOW`, `INPUT`, and `OUTPUT`. +[%hardbreaks] + +-- +// OVERVIEW SECTION ENDS + + + +// SEE ALSO SECTION BEGINS +[#see_also] +-- + +[float] +=== See also + +[role="language"] + +-- +// SEE ALSO SECTION ENDS \ No newline at end of file From 06fce54965e22fbf16278ba12b4b92815eb2ce01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:28:14 +0100 Subject: [PATCH 151/184] Delete constants.adoc --- Language/Variables/Constants/constants.adoc | 131 -------------------- 1 file changed, 131 deletions(-) delete mode 100644 Language/Variables/Constants/constants.adoc diff --git a/Language/Variables/Constants/constants.adoc b/Language/Variables/Constants/constants.adoc deleted file mode 100644 index 05f137654..000000000 --- a/Language/Variables/Constants/constants.adoc +++ /dev/null @@ -1,131 +0,0 @@ ---- -title: constants -categories: [ "Variables" ] -subCategories: [ "Constants" ] ---- - -= Constants - - -// OVERVIEW SECTION STARTS -[#overview] --- - -[float] -== Description -Constants are predefined expressions in the Arduino language. They are used to make the programs easier to read. We classify constants in groups: - -[float] -== Defining Logical Levels: true and false (Boolean Constants) -There are two constants used to represent truth and falsity in the Arduino language: `true`, and `false`. - -[float] -=== false -`false` is the easier of the two to define. false is defined as 0 (zero). -[%hardbreaks] - -[float] -=== true -`true` is often said to be defined as 1, which is correct, but true has a wider definition. Any integer which is non-zero is true, in a Boolean sense. So -1, 2 and -200 are all defined as true, too, in a Boolean sense. -[%hardbreaks] - -Note that the `true` and `false` constants are typed in lowercase unlike `HIGH`, `LOW`, `INPUT`, and `OUTPUT`. -[%hardbreaks] - -[float] -== Defining Pin Levels: HIGH and LOW -When reading or writing to a digital pin there are only two possible values a pin can take/be-set-to: `HIGH` and `LOW`. - -[float] -=== HIGH -The meaning of `HIGH` (in reference to a pin) is somewhat different depending on whether a pin is set to an `INPUT` or `OUTPUT`. When a pin is configured as an `INPUT` with `link:../../../functions/digital-io/pinmode[pinMode()]`, and read with `link:../../../functions/digital-io/digitalread[digitalRead()]`, the Arduino (ATmega) will report `HIGH` if: - - - a voltage greater than 3.0V is present at the pin (5V boards) - - a voltage greater than 2.0V is present at the pin (3.3V boards) -[%hardbreaks] - -A pin may also be configured as an INPUT with link:../../../functions/digital-io/pinmode[`pinMode()`], and subsequently made HIGH with `link:../../../functions/digital-io/digitalwrite[digitalWrite()]`. This will enable the internal 20K pullup resistors, which will _pull up_ the input pin to a `HIGH` reading unless it is pulled `LOW` by external circuitry. This can be done alternatively by passing `INPUT_PULLUP` as argument to the link:../../../functions/digital-io/pinmode[`pinMode()`] function, as explained in more detail in the section "Defining Digital Pins modes: INPUT, INPUT_PULLUP, and OUTPUT" further below. -[%hardbreaks] - -When a pin is configured to OUTPUT with link:../../../functions/digital-io/pinmode[`pinMode()`], and set to `HIGH` with link:../../../functions/digital-io/digitalwrite[`digitalWrite()`], the pin is at: - - - 5 volts (5V boards) - - 3.3 volts (3.3V boards) - -In this state it can source current, e.g. light an LED that is connected through a series resistor to ground. -[%hardbreaks] - -[float] -=== LOW -The meaning of `LOW` also has a different meaning depending on whether a pin is set to `INPUT` or `OUTPUT`. When a pin is configured as an `INPUT` with link:../../../functions/digital-io/pinmode[`pinMode()`], and read with link:../../../functions/digital-io/digitalread[`digitalRead()`], the Arduino (ATmega) will report LOW if: - - - a voltage less than 1.5V is present at the pin (5V boards) - - a voltage less than 1.0V (Approx) is present at the pin (3.3V boards) - -When a pin is configured to `OUTPUT` with link:../../../functions/digital-io/pinmode[`pinMode()`], and set to `LOW` with link:../../../functions/digital-io/digitalwrite[`digitalWrite()`], the pin is at 0 volts (both 5V and 3.3V boards). In this state it can sink current, e.g. light an LED that is connected through a series resistor to +5 volts (or +3.3 volts). -[%hardbreaks] - -[float] -== Defining Digital Pins modes: INPUT, INPUT_PULLUP, and OUTPUT -Digital pins can be used as `INPUT`, `INPUT_PULLUP`, or `OUTPUT`. Changing a pin with link:../../../functions/digital-io/pinmode[`pinMode()`] changes the electrical behavior of the pin. - -[float] -=== Pins Configured as INPUT -Arduino (ATmega) pins configured as `INPUT` with link:../../../functions/digital-io/pinmode[`pinMode()`] are said to be in a _high-impedance_ state. Pins configured as `INPUT` make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 Megohms in front of the pin. This makes them useful for reading a sensor. -[%hardbreaks] - -If you have your pin configured as an `INPUT`, and are reading a switch, when the switch is in the open state the input pin will be "floating", resulting in unpredictable results. In order to assure a proper reading when the switch is open, a pull-up or pull-down resistor must be used. The purpose of this resistor is to pull the pin to a known state when the switch is open. A 10 K ohm resistor is usually chosen, as it is a low enough value to reliably prevent a floating input, and at the same time a high enough value to not draw too much current when the switch is closed. See the http://arduino.cc/en/Tutorial/DigitalReadSerial[Digital Read Serial^] tutorial for more information. -[%hardbreaks] - -If a pull-down resistor is used, the input pin will be `LOW` when the switch is open and `HIGH` when the switch is closed. -[%hardbreaks] - -If a pull-up resistor is used, the input pin will be `HIGH` when the switch is open and `LOW` when the switch is closed. -[%hardbreaks] - -[float] -=== Pins Configured as INPUT_PULLUP -The ATmega microcontroller on the Arduino has internal pull-up resistors (resistors that connect to power internally) that you can access. If you prefer to use these instead of external pull-up resistors, you can use the `INPUT_PULLUP` argument in link:../../../functions/digital-io/pinmode[`pinMode()`]. -[%hardbreaks] - -See the http://arduino.cc/en/Tutorial/InputPullupSerial[Input Pullup Serial^] tutorial for an example of this in use. -[%hardbreaks] - -Pins configured as inputs with either `INPUT` or `INPUT_PULLUP` can be damaged or destroyed if they are connected to voltages below ground (negative voltages) or above the positive power rail (5V or 3V). -[%hardbreaks] - -[float] -=== Pins Configured as OUTPUT -Pins configured as `OUTPUT` with link:../../../functions/digital-io/pinmode[`pinMode()`] are said to be in a _low-impedance_ state. This means that they can provide a substantial amount of current to other circuits. ATmega pins can source (provide current) or sink (absorb current) up to 40 mA (milliamps) of current to other devices/circuits. This makes them useful for powering LEDs because LEDs typically use less than 40 mA. Loads greater than 40 mA (e.g. motors) will require a transistor or other interface circuitry. -[%hardbreaks] - -Pins configured as outputs can be damaged or destroyed if they are connected to either the ground or positive power rails. -[%hardbreaks] - -[float] -== Defining built-ins: LED_BUILTIN -Most Arduino boards have a pin connected to an on-board LED in series with a resistor. The constant `LED_BUILTIN` is the number of the pin to which the on-board LED is connected. Most boards have this LED connected to digital pin 13. - --- -// OVERVIEW SECTION ENDS - - - -// HOW TO USE SECTION STARTS -[#howtouse] --- - --- -// HOW TO USE SECTION ENDS - -// SEE ALSO SECTION BEGINS -[#see_also] --- - -[float] -=== See also - -[role="language"] - --- -// SEE ALSO SECTION ENDS From c3733c89ba7c0bb60f78fc19b4f202d0ca2517fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:32:44 +0100 Subject: [PATCH 152/184] Constant Link fixes --- Language/Functions/Advanced IO/pulseIn.adoc | 2 +- Language/Functions/Advanced IO/pulseInLong.adoc | 2 +- Language/Structure/Control Structure/doWhile.adoc | 2 +- Language/Structure/Control Structure/for.adoc | 4 ++-- Language/Structure/Further Syntax/define.adoc | 1 - Language/Variables/Data Types/bool.adoc | 4 +--- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Language/Functions/Advanced IO/pulseIn.adoc b/Language/Functions/Advanced IO/pulseIn.adoc index 1a34dc93e..5252f6814 100644 --- a/Language/Functions/Advanced IO/pulseIn.adoc +++ b/Language/Functions/Advanced IO/pulseIn.adoc @@ -34,7 +34,7 @@ NOTE: if the optional timeout is used code will execute faster. [float] === Parameters `pin`: the number of the Arduino pin on which you want to read the pulse. Allowed data types: `int`. + -`value`: type of pulse to read: either link:../../../variables/constants/constants[HIGH] or link:../../../variables/constants/constants[LOW]. Allowed data types: `int`. + +`value`: type of pulse to read: either link:../../../variables/constants/highlow/[HIGH] or link:../../../variables/constants/highlow/[LOW]. Allowed data types: `int`. + `timeout` (optional): the number of microseconds to wait for the pulse to start; default is one second. Allowed data types: `unsigned long`. diff --git a/Language/Functions/Advanced IO/pulseInLong.adoc b/Language/Functions/Advanced IO/pulseInLong.adoc index 2517f6533..1fdc88a1c 100644 --- a/Language/Functions/Advanced IO/pulseInLong.adoc +++ b/Language/Functions/Advanced IO/pulseInLong.adoc @@ -34,7 +34,7 @@ The timing of this function has been determined empirically and will probably sh [float] === Parameters `pin`: the number of the Arduino pin on which you want to read the pulse. Allowed data types: `int`. + -`value`: type of pulse to read: either link:../../../variables/constants/constants[HIGH] or link:../../../variables/constants/constants[LOW]. Allowed data types: `int`. + +`value`: type of pulse to read: either link:../../../variables/constants/highlow/[HIGH] or link:../../../variables/constants/highlow/[LOW]. Allowed data types: `int`. + `timeout` (optional): the number of microseconds to wait for the pulse to start; default is one second. Allowed data types: `unsigned long`. diff --git a/Language/Structure/Control Structure/doWhile.adoc b/Language/Structure/Control Structure/doWhile.adoc index 8651f957e..033d32b9c 100644 --- a/Language/Structure/Control Structure/doWhile.adoc +++ b/Language/Structure/Control Structure/doWhile.adoc @@ -32,7 +32,7 @@ do { [float] === Parameters -`condition`: a boolean expression that evaluates to `link:../../../variables/constants/constants[true]` or `link:../../../variables/constants/constants[false]`. +`condition`: a boolean expression that evaluates to `link:../../../variables/constants/truefalse[true]` or `link:../../../variables/constants/truefalse[false]`. -- // OVERVIEW SECTION ENDS diff --git a/Language/Structure/Control Structure/for.adoc b/Language/Structure/Control Structure/for.adoc index 7e02a21f7..533ce1079 100644 --- a/Language/Structure/Control Structure/for.adoc +++ b/Language/Structure/Control Structure/for.adoc @@ -34,8 +34,8 @@ for (initialization; condition; increment) { [float] === Parameters `initialization`: happens first and exactly once. + -`condition`: each time through the loop, `condition` is tested; if it's `link:../../../variables/constants/constants[true]`, the statement block, and the *increment* is executed, then the *condition* is tested again. When the *condition* becomes `link:../../../variables/constants/constants[false]`, the loop ends. + -`increment`: executed each time through the loop when `condition` is link:../../../variables/constants/constants[`true`]. +`condition`: each time through the loop, `condition` is tested; if it's `link:../../../variables/constants/truefalse[true]`, the statement block, and the *increment* is executed, then the *condition* is tested again. When the *condition* becomes `link:../../../variables/constants/truefalse[false]`, the loop ends. + +`increment`: executed each time through the loop when `condition` is link:../../../variables/constants/truefalse[`true`]. -- // OVERVIEW SECTION ENDS diff --git a/Language/Structure/Further Syntax/define.adoc b/Language/Structure/Further Syntax/define.adoc index 99c197705..c04df008f 100644 --- a/Language/Structure/Further Syntax/define.adoc +++ b/Language/Structure/Further Syntax/define.adoc @@ -89,7 +89,6 @@ Similarly, including an equal sign after the #define statement will also generat [role="language"] * #LANGUAGE# link:../../../variables/variable-scope-qualifiers/const[const] -* #LANGUAGE# link:../../../variables/constants/constants[Constants] -- // SEE ALSO SECTION ENDS diff --git a/Language/Variables/Data Types/bool.adoc b/Language/Variables/Data Types/bool.adoc index 6145dab3a..b6e0cb199 100644 --- a/Language/Variables/Data Types/bool.adoc +++ b/Language/Variables/Data Types/bool.adoc @@ -12,7 +12,7 @@ subCategories: [ "Data Types" ] [float] === Description -A `bool` holds one of two values, `link:../../constants/constants[true]` or `link:../../constants/constants[false]`. (Each `bool` variable occupies one byte of memory.) +A `bool` holds one of two values, `link:../../constants/truefalse[true]` or `link:../../constants/truefalse[false]`. (Each `bool` variable occupies one byte of memory.) [%hardbreaks] @@ -77,8 +77,6 @@ void loop() { [float] === See also -[role="language"] -* #LANGUAGE# link:../../../variables/constants/constants[constants] -- // SEE ALSO SECTION ENDS From 573e220457fbcb397c817d26bfa16f4652cacef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:55:40 +0100 Subject: [PATCH 153/184] Apply suggestions from code review --- Language/Functions/Communication/SPI.adoc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index d7ec8c9cd..34fdb9766 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -32,13 +32,15 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le -- |================================================================================================================================================ | Boards | SPI Pins | SPI Headers | -| Leonardo, UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd, UNO R4 Minima, UNO R4 WiFi, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | +| UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | +| UNO R4 Minima, UNO R4 WiFi| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | +| Leonardo, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | | Micro | 14(CIPO), 15(SCK), 16(COPI) | | | Nano boards | 11(COPI), 12(CIPO), 13(SCK) | | | MKR boards | 8(COPI), 9(SCK), 10(CIPO) | | -| Due | | 74(CIPO), 75(MOSI), 76(SCK) | +| Due | 74(CIPO), 75(MOSI), 76(SCK) | | | GIGA R1 WiFi | 12(CIPO), 11(COPI), 13(SCK), 10(CS) | 89(CIPO), 90(COPI), 91(SCK) | -| Mega 2560 Rev3 | | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | +| Mega 2560 Rev3 | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | | |================================================================================================================================================ -- From dfc40bc9beba8b7f74597b7e33f27fcf67960730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:55:47 +0100 Subject: [PATCH 154/184] Update Language/Functions/Communication/SPI.adoc --- Language/Functions/Communication/SPI.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index 34fdb9766..f5c9521cc 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -31,7 +31,7 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le [#howtouse] -- |================================================================================================================================================ -| Boards | SPI Pins | SPI Headers | +| Boards | Default SPI Pins | Additonal SPI Pins | | UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | | UNO R4 Minima, UNO R4 WiFi| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | | Leonardo, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | From 70f7b9c5835ff8288d3cce1d298214fd9b055e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:57:27 +0100 Subject: [PATCH 155/184] Update Language/Functions/Communication/SPI.adoc --- Language/Functions/Communication/SPI.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index f5c9521cc..364cbfb37 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -39,7 +39,7 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le | Nano boards | 11(COPI), 12(CIPO), 13(SCK) | | | MKR boards | 8(COPI), 9(SCK), 10(CIPO) | | | Due | 74(CIPO), 75(MOSI), 76(SCK) | | -| GIGA R1 WiFi | 12(CIPO), 11(COPI), 13(SCK), 10(CS) | 89(CIPO), 90(COPI), 91(SCK) | +| GIGA R1 WiFi | 89(CIPO), 90(COPI), 91(SCK) | 12(CIPO), 11(COPI), 13(SCK), 10(CS) | | Mega 2560 Rev3 | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | | |================================================================================================================================================ From 7fff021eb2c94244d84ee21df50f1a7923d5dd2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 28 Nov 2023 16:01:05 +0100 Subject: [PATCH 156/184] Apply suggestions from code review --- Language/Functions/Communication/SPI.adoc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index 364cbfb37..d99d60d29 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -31,16 +31,16 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le [#howtouse] -- |================================================================================================================================================ -| Boards | Default SPI Pins | Additonal SPI Pins | -| UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | -| UNO R4 Minima, UNO R4 WiFi| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | -| Leonardo, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | +| Boards | Default SPI Pins | Additonal SPI Pins | Notes | +| UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header | +| UNO R4 Minima, UNO R4 WiFi| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header | +| Leonardo, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header | | Micro | 14(CIPO), 15(SCK), 16(COPI) | | | Nano boards | 11(COPI), 12(CIPO), 13(SCK) | | | MKR boards | 8(COPI), 9(SCK), 10(CIPO) | | -| Due | 74(CIPO), 75(MOSI), 76(SCK) | | -| GIGA R1 WiFi | 89(CIPO), 90(COPI), 91(SCK) | 12(CIPO), 11(COPI), 13(SCK), 10(CS) | -| Mega 2560 Rev3 | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | | +| Due | 74(CIPO), 75(MOSI), 76(SCK) | SPI pins available on dedicated SPI header | | +| GIGA R1 WiFi | 89(CIPO), 90(COPI), 91(SCK) | 12(CIPO), 11(COPI), 13(SCK), 10(CS) | Note that pin 89,90,91 are located on the SPI header | +| Mega 2560 Rev3 | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | | SPI pins available on ICSP header | |================================================================================================================================================ -- From 960185a0db61055836e8a10619be2adb45497b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Thu, 30 Nov 2023 01:34:44 +0100 Subject: [PATCH 157/184] Updated list --- Language/Functions/Communication/Serial.adoc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Language/Functions/Communication/Serial.adoc b/Language/Functions/Communication/Serial.adoc index 21fb67ce1..1f2b05b35 100644 --- a/Language/Functions/Communication/Serial.adoc +++ b/Language/Functions/Communication/Serial.adoc @@ -18,16 +18,23 @@ subCategories: [ "Communication" ] === Description Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART), and some have several. [options="header"] + |================================================================================================================================================ | Board | USB CDC name | Serial pins | Serial1 pins | Serial2 pins | Serial3 pins -| Uno, Nano, Mini | | 0(RX), 1(TX) | | | -| Mega | | 0(RX), 1(TX) | 19(RX), 18(TX) | 17(RX), 16(TX) | 15(RX), 14(TX) -| Leonardo, Micro, Yún | Serial | | 0(RX), 1(TX) | | +| UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd, Mini| | | 0(RX), 1(TX) | | +| UNO R4 Minima, UNO R4 WiFi| | 18(RX), 17(TX) | | | +| Leonardo, Micro, Yún Rev2| Serial | | 0(RX), 1(TX) | | | Uno WiFi Rev.2 | | Connected to USB | 0(RX), 1(TX) | Connected to NINA | -| MKR boards | Serial | | 13(RX), 14(TX) | | -| Zero | SerialUSB (Native USB Port only) | Connected to Programming Port | 0(RX), 1(TX) | | +| Nano ESP32 | | 14(RX), 15(TX) | | | +| Nano 33 BLE, Nano 33 BLE Sense, Nano 33 BLE Sense Rev2, Nano 33 IoT, Nano Every | | 17(RX), 16(TX) | | | +| Nano RP2040 Connect, Nano | | 2(RX), 1(TX) | | | +| MKR boards | Serial | | 22(RX), 23(TX) | | +| MKR Zero | SerialUSB (Native USB Port only) | Connected to Programming Port | 0(RX), 1(TX) | | | Due | SerialUSB (Native USB Port only) | 0(RX), 1(TX) | 19(RX), 18(TX) | 17(RX), 16(TX) | 15(RX), 14(TX) | 101 | Serial | | 0(RX), 1(TX) | | +| GIGA R1 WiFi | | | 24(RX), 23(TX) | 22(RX), 21(TX) | 20(RX), 19(TX) +| Mega 2560 Rev3 | | 18(RX), 17(TX) | 24(RX), 23(TX) | 22(RX), 21(TX) | 20(RX), 19(TX) +| Mega | | 0(RX), 1(TX) | 19(RX), 18(TX) | 17(RX), 16(TX) | 15(RX), 14(TX) |================================================================================================================================================ On Uno, Nano, Mini, and Mega, pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board. From cb76050aa4b5ef046b7d141a741ce9b9abb20b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenjaminDanneg=C3=A5rd?= Date: Thu, 30 Nov 2023 06:08:49 +0100 Subject: [PATCH 158/184] Added table for boards --- Language/Functions/Communication/Wire.adoc | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Language/Functions/Communication/Wire.adoc b/Language/Functions/Communication/Wire.adoc index 26c3e6df2..b9aa4c089 100644 --- a/Language/Functions/Communication/Wire.adoc +++ b/Language/Functions/Communication/Wire.adoc @@ -20,20 +20,18 @@ This library allows you to communicate with I2C/TWI devices. On the Arduino boar As a reference the table below shows where TWI pins are located on various Arduino boards. -[cols="1,1"] -|=== -|Board -|I2C/TWI pins - -|UNO, Ethernet -|A4 (SDA), A5 (SCL) - -|Mega2560 -|20 (SDA), 21 (SCL) - -|Leonardo -|20 (SDA), 21 (SCL), SDA1, SCL1 -|=== +|================================================================================================================================================ +| Board | I2C/TWI pins | +| UNO R3 | 13(SDA), 14(SCL) | +| UNO R3 SMD, UNO Mini Ltd | 18(SDA), 19(SCL) | +| UNO WiFi Rev2 | 20(SDA), 21(SCL) | +| UNO R4 Minima, UNO R4 WiFi | 2(SDA), 1(SCL) | +| Micro, Yún Rev2 | D2(SDA), D3(SCL) | +| Leonardo, GIGA R1 WiFi | 20(SDA), 21(SCL), SDA1, SCL1 | +| Nano boards | A4(SDA), A5(SCL) | +| MKR boards | D11(SDA), D12(SCL) | +| Due, MKR Zero, Mega, Mega 2560 Rev3 | D20(SDA), D21(SCL) | +|================================================================================================================================================ This library inherits from the Stream functions, making it consistent with other read/write libraries. Because of this, `send()` and `receive()` have been replaced with `read()` and `write()`. From 017eec0ac96b3ef9bd462c0122a4ab17681b1857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:04:52 +0100 Subject: [PATCH 159/184] Update Language/Functions/Bits and Bytes/bit.adoc --- Language/Functions/Bits and Bytes/bit.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Bits and Bytes/bit.adoc b/Language/Functions/Bits and Bytes/bit.adoc index 6127e2802..3aaeda82b 100644 --- a/Language/Functions/Bits and Bytes/bit.adoc +++ b/Language/Functions/Bits and Bytes/bit.adoc @@ -28,7 +28,7 @@ Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc [float] === Parameters -`n`: the bit whose value to compute. 0 <= n < 32 (as it is intended to reflect the bits up to 31 of a uint32) +`n`: the bit whose value to compute. Note that `n` needs to be between 0-31 (32 bit). [float] From c3bfc047455251ae220c22f3bef7064a30d143e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:32:34 +0100 Subject: [PATCH 160/184] Update Language/Structure/Control Structure/for.adoc Co-authored-by: per1234 --- Language/Structure/Control Structure/for.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Structure/Control Structure/for.adoc b/Language/Structure/Control Structure/for.adoc index 6724e1e58..d677f58ba 100644 --- a/Language/Structure/Control Structure/for.adoc +++ b/Language/Structure/Control Structure/for.adoc @@ -52,7 +52,7 @@ for (initialization; condition; increment) { [source,arduino] ---- // Brighten an LED using a PWM pin -int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10 +int PWMpin = 10; // LED in series with 470 ohm resistor from pin 10 to ground void setup() { // no setup needed From b6036005f1e78456bde723ec2cbef4cc209fb839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:03:00 +0100 Subject: [PATCH 161/184] Update Language/Functions/Communication/Wire.adoc --- Language/Functions/Communication/Wire.adoc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Language/Functions/Communication/Wire.adoc b/Language/Functions/Communication/Wire.adoc index b9aa4c089..f556e3310 100644 --- a/Language/Functions/Communication/Wire.adoc +++ b/Language/Functions/Communication/Wire.adoc @@ -21,16 +21,16 @@ This library allows you to communicate with I2C/TWI devices. On the Arduino boar As a reference the table below shows where TWI pins are located on various Arduino boards. |================================================================================================================================================ -| Board | I2C/TWI pins | -| UNO R3 | 13(SDA), 14(SCL) | -| UNO R3 SMD, UNO Mini Ltd | 18(SDA), 19(SCL) | -| UNO WiFi Rev2 | 20(SDA), 21(SCL) | -| UNO R4 Minima, UNO R4 WiFi | 2(SDA), 1(SCL) | -| Micro, Yún Rev2 | D2(SDA), D3(SCL) | -| Leonardo, GIGA R1 WiFi | 20(SDA), 21(SCL), SDA1, SCL1 | -| Nano boards | A4(SDA), A5(SCL) | -| MKR boards | D11(SDA), D12(SCL) | -| Due, MKR Zero, Mega, Mega 2560 Rev3 | D20(SDA), D21(SCL) | +| Board | I2C Default | I2C1 | I2C2 | Notes +| UNO R3, UNO R3 SMD, UNO Mini Ltd | A4(SDA), A5(SCL) | | | I2C also available on the SDA / SCL pins (digital header). +| UNO R4 Minima, UNO R4 WiFi | A4(SDA), A5(SCL) | Qwiic: D27(SDA), D26(SCL) | | I2C also available on the SDA / SCL pins (digital header). +| UNO WiFi Rev2, Zero | 20(SDA), 21(SCL) | | | +| Leonardo, Micro, Yùn Rev2 | D2(SDA), D3(SCL) | | | +| Nano boards | A4(SDA), A5(SCL) | | | +| MKR boards | D11(SDA), D12(SCL) | | | +| GIGA R1 WiFi | 20(SDA), 21(SCL) | D102(SDA1), D101 (SCL1) | D9(SDA2), D8 (SCL2) | Use `Wire1.begin()` for I2C1, and `Wire2.begin()` for I2C2. +| Due | 20(SDA), 21(SCL) | D70(SDA1), D71(SCL1) | | Use `Wire1.begin()` for I2C1 +| Mega 2560 Rev3 | D20(SDA), D21(SCL) | | | |================================================================================================================================================ From b4411d226a300eb930d72e94ea0d4396b8315451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:20:43 +0100 Subject: [PATCH 162/184] Update Wire.adoc --- Language/Functions/Communication/Wire.adoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Communication/Wire.adoc b/Language/Functions/Communication/Wire.adoc index f556e3310..4aed17dc7 100644 --- a/Language/Functions/Communication/Wire.adoc +++ b/Language/Functions/Communication/Wire.adoc @@ -16,9 +16,10 @@ subCategories: [ "Communication" ] === Description -This library allows you to communicate with I2C/TWI devices. On the Arduino boards with the R3 layout, the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. The Arduino Due has two I2C/TWI interfaces SDA1 and SCL1 are near to the AREF pin and the additional one is on pins 20 and 21. +This library allows you to communicate with I2C devices, a feature that is present on all Arduino boards. I2C is a very common protocol, primarly used for reading/sending data to/from external I2C components. To learn more, visit link:https://docs.arduino.cc/learn/communication/wire[this article for Arduino & I2C]. + +Due to the hardware design and various architectural differences, the I2C pins are located in different places. The pin map just below highlights the default pins, as well as additional ports available on certain boards. -As a reference the table below shows where TWI pins are located on various Arduino boards. |================================================================================================================================================ | Board | I2C Default | I2C1 | I2C2 | Notes From e660fd9d5c7e4cf5a7dbb60f338a3740a9bbac66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 6 Dec 2023 11:13:07 +0100 Subject: [PATCH 163/184] Update serialEvent.adoc --- Language/Functions/Communication/Serial/serialEvent.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Language/Functions/Communication/Serial/serialEvent.adoc b/Language/Functions/Communication/Serial/serialEvent.adoc index c1b4e8c11..584de8ec3 100644 --- a/Language/Functions/Communication/Serial/serialEvent.adoc +++ b/Language/Functions/Communication/Serial/serialEvent.adoc @@ -15,6 +15,8 @@ title: serialEvent() [float] === Description Called at the end of link:../../../../structure/sketch/loop[`loop()`] when data is available. Use `Serial.read()` to capture this data. + +*Please note:* most modern boards do not support this method. See "Notes and Warnings" further below this article. [%hardbreaks] @@ -63,11 +65,9 @@ Nothing [float] === Notes and Warnings -`serialEvent()` doesn't work on the Leonardo, Micro, or Yún. - -`serialEvent()` and `serialEvent1()` don't work on the Arduino SAMD Boards +Please note that `serialEvent()` *does not work* on any modern Arduino boards. The only recognized boards to have support as of 2023/12/06 is the *UNO R3* and *Mega 2560 R3*, which are based on the ATmega328P chip. -`serialEvent()`, `serialEvent1()`, `serialEvent2()`, and `serialEvent3()` don't work on the Arduino Due. +Instead, you can use the link:../available[`available()`] method. Examples in this page demonstrates how to read serial data only when it is available, which is exactly what `Serial.event()` does. [%hardbreaks] -- From 1374589d76c48a956d7e604d539a36b27e96f2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 6 Dec 2023 11:16:01 +0100 Subject: [PATCH 164/184] Update serialEvent.adoc --- Language/Functions/Communication/Serial/serialEvent.adoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Communication/Serial/serialEvent.adoc b/Language/Functions/Communication/Serial/serialEvent.adoc index 584de8ec3..f6a7ebfa4 100644 --- a/Language/Functions/Communication/Serial/serialEvent.adoc +++ b/Language/Functions/Communication/Serial/serialEvent.adoc @@ -29,7 +29,9 @@ void serialEvent() { //statements } ---- -For boards with additional serial ports (see the list of available serial ports for each board on the link:../../serial[Serial main page]): + +The Mega 2560 R3 has additional serial ports which can be accessed by adding the corresponding number at the end of the function. + [source,arduino] ---- void serialEvent1() { @@ -65,7 +67,7 @@ Nothing [float] === Notes and Warnings -Please note that `serialEvent()` *does not work* on any modern Arduino boards. The only recognized boards to have support as of 2023/12/06 is the *UNO R3* and *Mega 2560 R3*, which are based on the ATmega328P chip. +Please note that `serialEvent()` *does not work* on any modern Arduino boards. The only recognized boards to have support as of 2023/12/06 is the *UNO R3* and *Mega 2560 R3*, which are based on the ATmega328P and ATmega2560 chips. Instead, you can use the link:../available[`available()`] method. Examples in this page demonstrates how to read serial data only when it is available, which is exactly what `Serial.event()` does. [%hardbreaks] From 6b28b9de8af38e487428e2d95d56cfd5b8aefa7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 6 Dec 2023 11:32:56 +0100 Subject: [PATCH 165/184] Update serialEvent.adoc --- Language/Functions/Communication/Serial/serialEvent.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Language/Functions/Communication/Serial/serialEvent.adoc b/Language/Functions/Communication/Serial/serialEvent.adoc index f6a7ebfa4..547d06701 100644 --- a/Language/Functions/Communication/Serial/serialEvent.adoc +++ b/Language/Functions/Communication/Serial/serialEvent.adoc @@ -30,7 +30,7 @@ void serialEvent() { } ---- -The Mega 2560 R3 has additional serial ports which can be accessed by adding the corresponding number at the end of the function. +The Mega 2560 R3 and Due boards have additional serial ports which can be accessed by adding the corresponding number at the end of the function. [source,arduino] ---- @@ -67,9 +67,9 @@ Nothing [float] === Notes and Warnings -Please note that `serialEvent()` *does not work* on any modern Arduino boards. The only recognized boards to have support as of 2023/12/06 is the *UNO R3* and *Mega 2560 R3*, which are based on the ATmega328P and ATmega2560 chips. +Please note that `serialEvent()` *does not work* on any modern Arduino boards. The only recognized boards to have support as of 2023/12/06 is the *UNO R3*, *Mega 2560 R3* and *Due*. -Instead, you can use the link:../available[`available()`] method. Examples in this page demonstrates how to read serial data only when it is available, which is exactly what `Serial.event()` does. +Instead, you can use the link:../available[`available()`] method. Examples in this page demonstrates how to read serial data only when it is available, similarly to how `Serial.event()` is implemented. [%hardbreaks] -- From 193aba87f62aa5badfba8da5bba96366d9b64fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:28:40 +0100 Subject: [PATCH 166/184] Serial Table update --- Language/Functions/Communication/Serial.adoc | 33 +++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/Language/Functions/Communication/Serial.adoc b/Language/Functions/Communication/Serial.adoc index 1f2b05b35..2342f7251 100644 --- a/Language/Functions/Communication/Serial.adoc +++ b/Language/Functions/Communication/Serial.adoc @@ -4,9 +4,6 @@ categories: [ "Functions" ] subCategories: [ "Communication" ] --- - - - = Serial() @@ -20,24 +17,22 @@ Used for communication between the Arduino board and a computer or other devices [options="header"] |================================================================================================================================================ -| Board | USB CDC name | Serial pins | Serial1 pins | Serial2 pins | Serial3 pins -| UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd, Mini| | | 0(RX), 1(TX) | | -| UNO R4 Minima, UNO R4 WiFi| | 18(RX), 17(TX) | | | -| Leonardo, Micro, Yún Rev2| Serial | | 0(RX), 1(TX) | | -| Uno WiFi Rev.2 | | Connected to USB | 0(RX), 1(TX) | Connected to NINA | -| Nano ESP32 | | 14(RX), 15(TX) | | | -| Nano 33 BLE, Nano 33 BLE Sense, Nano 33 BLE Sense Rev2, Nano 33 IoT, Nano Every | | 17(RX), 16(TX) | | | -| Nano RP2040 Connect, Nano | | 2(RX), 1(TX) | | | -| MKR boards | Serial | | 22(RX), 23(TX) | | -| MKR Zero | SerialUSB (Native USB Port only) | Connected to Programming Port | 0(RX), 1(TX) | | -| Due | SerialUSB (Native USB Port only) | 0(RX), 1(TX) | 19(RX), 18(TX) | 17(RX), 16(TX) | 15(RX), 14(TX) -| 101 | Serial | | 0(RX), 1(TX) | | -| GIGA R1 WiFi | | | 24(RX), 23(TX) | 22(RX), 21(TX) | 20(RX), 19(TX) -| Mega 2560 Rev3 | | 18(RX), 17(TX) | 24(RX), 23(TX) | 22(RX), 21(TX) | 20(RX), 19(TX) -| Mega | | 0(RX), 1(TX) | 19(RX), 18(TX) | 17(RX), 16(TX) | 15(RX), 14(TX) +| Board | Serial pins | Serial1 pins | Serial2 pins | Serial3 pins +| UNO R3, UNO R3 SMD Mini | 0(RX), 1(TX) | | | +| UNO R4 Minima, UNO R4 WiFi| 18(RX), 17(TX) | | | +| Leonardo, Micro, Yún Rev2 | 0(RX), 1(TX) | | | +| Uno WiFi Rev.2 | 0(RX), 1(TX) | | | +| 101 | 0(RX), 1(TX) | | | +| MKR boards | 13(RX), 14(TX) | | | +| Nano boards | 0(RX), 1(TX) | | | +| Zero | 0(RX), 1(TX) | | | +| Due | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) +| GIGA R1 WiFi | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) +| Mega 2560 Rev3 | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) |================================================================================================================================================ -On Uno, Nano, Mini, and Mega, pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board. + +On older boards (Uno, Nano, Mini, and Mega), pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board. [%hardbreaks] You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to `begin()`. [%hardbreaks] From 7f80982a392ba130b6bfd6886c411a84ec64ffe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:01:39 +0100 Subject: [PATCH 167/184] Update bitRead.adoc --- Language/Functions/Bits and Bytes/bitRead.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/Language/Functions/Bits and Bytes/bitRead.adoc b/Language/Functions/Bits and Bytes/bitRead.adoc index 4c4cb9346..53c190c6a 100644 --- a/Language/Functions/Bits and Bytes/bitRead.adoc +++ b/Language/Functions/Bits and Bytes/bitRead.adoc @@ -36,6 +36,7 @@ Reads a bit of a variable, e.g. `bool`, `int`. Note that `float` & `double` are === Returns The value of the bit (0 or 1). +[float] === Example Code This example code demonstrates how to read two variables, one increasing counter, one decreasing counter, and print out both the binary and decimal values of the variables. From 278a46aaf4a7d43322d25fc65f32bc2349390d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 11 Dec 2023 10:09:58 +0100 Subject: [PATCH 168/184] Add Nano --- Language/Functions/Communication/Serial/serialEvent.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Serial/serialEvent.adoc b/Language/Functions/Communication/Serial/serialEvent.adoc index 547d06701..80475fe00 100644 --- a/Language/Functions/Communication/Serial/serialEvent.adoc +++ b/Language/Functions/Communication/Serial/serialEvent.adoc @@ -67,7 +67,7 @@ Nothing [float] === Notes and Warnings -Please note that `serialEvent()` *does not work* on any modern Arduino boards. The only recognized boards to have support as of 2023/12/06 is the *UNO R3*, *Mega 2560 R3* and *Due*. +Please note that `serialEvent()` *does not work* on any modern Arduino boards. The only recognized boards to have support as of 2023/12/06 are the *UNO R3*, *Nano*, *Mega 2560 R3* and *Due*. Instead, you can use the link:../available[`available()`] method. Examples in this page demonstrates how to read serial data only when it is available, similarly to how `Serial.event()` is implemented. [%hardbreaks] From 2ac5be01aa599a3f2e1a7721c8f94c77b7494777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:42:51 +0100 Subject: [PATCH 169/184] Apply suggestions from code review Co-authored-by: per1234 --- Language/Functions/Bits and Bytes/bitSet.adoc | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Language/Functions/Bits and Bytes/bitSet.adoc b/Language/Functions/Bits and Bytes/bitSet.adoc index 828daebf6..94c52a797 100644 --- a/Language/Functions/Bits and Bytes/bitSet.adoc +++ b/Language/Functions/Bits and Bytes/bitSet.adoc @@ -34,13 +34,23 @@ Sets (writes a 1 to) a bit of a numeric variable. [float] === Returns -x: the value of the numeric variable after the bit at position n is set. +`x`: the value of the numeric variable after the bit at position `n` is set. + +-- +// OVERVIEW SECTION ENDS + +// HOW TO USE SECTION STARTS +[#howtouse] +-- + [float] === Example Code -Prints the output of bitSet(x,n) on two given integers. The binary representation of 4 is 0100, so when n=1, the second bit from the right is set to 1. After this we are left with 0110 in binary, so 6 is returned. +Prints the output of `bitSet(x,n)` on two given integers. The binary representation of 4 is 0100, so when `n=1`, the second bit from the right is set to 1. After this we are left with 0110 in binary, so 6 is returned. +[source,arduino] +---- void setup() { Serial.begin(9600); while (!Serial) { @@ -54,9 +64,11 @@ void setup() { void loop() { } +---- +[%hardbreaks] -- -// OVERVIEW SECTION ENDS +// HOW TO USE SECTION ENDS // SEE ALSO SECTION @@ -65,7 +77,9 @@ void loop() { [float] === See also -bitClear() + +[role="language"] +* #LANGUAGE# link:../bitclear[bitClear()] -- // SEE ALSO SECTION ENDS From 57308eca22c2be45f8b131fc1d1066980a03dbda Mon Sep 17 00:00:00 2001 From: David Brown Date: Fri, 22 Dec 2023 22:15:59 -0500 Subject: [PATCH 170/184] Volatile variable name is now `changed`, not `state` A previous version of this page had different example code. This updates the introduction to the example to use the current example's volatile variable name. --- Language/Variables/Variable Scope & Qualifiers/volatile.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Variable Scope & Qualifiers/volatile.adoc b/Language/Variables/Variable Scope & Qualifiers/volatile.adoc index 79927f386..8845e1100 100644 --- a/Language/Variables/Variable Scope & Qualifiers/volatile.adoc +++ b/Language/Variables/Variable Scope & Qualifiers/volatile.adoc @@ -55,7 +55,7 @@ There are several ways to do this: === Example Code // Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄ -The `volatile` modifier ensures that changes to the `state` variable are immediately visible in `loop()`. Without the `volatile` modifier, the `state` variable may be loaded into a register when entering the function and would not be updated anymore until the function ends. +The `volatile` modifier ensures that changes to the `changed` variable are immediately visible in `loop()`. Without the `volatile` modifier, the `changed` variable may be loaded into a register when entering the function and would not be updated anymore until the function ends. [source,arduino] ---- From 04db291ed7b2c2e1e540834de270e7a05995ced1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 2 Jan 2024 12:05:50 +0100 Subject: [PATCH 171/184] Fix incorrect links in table for HID API --- Language/Functions/USB/Keyboard.adoc | 3 +-- Language/Functions/USB/Mouse.adoc | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Language/Functions/USB/Keyboard.adoc b/Language/Functions/USB/Keyboard.adoc index f1d9c565a..6773f0e69 100644 --- a/Language/Functions/USB/Keyboard.adoc +++ b/Language/Functions/USB/Keyboard.adoc @@ -36,9 +36,8 @@ HID is supported on the following boards: | link:https://docs.arduino.cc/hardware/zero[Zero] | All digital & analog pins | link:https://docs.arduino.cc/hardware/uno-r4-minima[UNO R4 Minima] | All digital & analog pins | link:https://docs.arduino.cc/hardware/uno-r4-wifi[UNO R4 WiFi] | All digital & analog pins -| link:https://docs.arduino.cc/hardware/giga-r1[Giga R1] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/giga-r1-wifi[Giga R1] | All digital & analog pins | link:https://docs.arduino.cc/hardware/nano-esp32[Nano ESP32] | All digital & analog pins -| link:https://docs.arduino.cc/hardware/mkr-1000-wifi[Nano ESP32] | All digital & analog pins | link:https://docs.arduino.cc/#mkr-family[MKR Family] | All digital & analog pins |================================================================================================= diff --git a/Language/Functions/USB/Mouse.adoc b/Language/Functions/USB/Mouse.adoc index c4c8e3865..b4a8400b8 100644 --- a/Language/Functions/USB/Mouse.adoc +++ b/Language/Functions/USB/Mouse.adoc @@ -35,9 +35,8 @@ HID is supported on the following boards: | link:https://docs.arduino.cc/hardware/zero[Zero] | All digital & analog pins | link:https://docs.arduino.cc/hardware/uno-r4-minima[UNO R4 Minima] | All digital & analog pins | link:https://docs.arduino.cc/hardware/uno-r4-wifi[UNO R4 WiFi] | All digital & analog pins -| link:https://docs.arduino.cc/hardware/giga-r1[Giga R1] | All digital & analog pins +| link:https://docs.arduino.cc/hardware/giga-r1-wifi[Giga R1] | All digital & analog pins | link:https://docs.arduino.cc/hardware/nano-esp32[Nano ESP32] | All digital & analog pins -| link:https://docs.arduino.cc/hardware/mkr-1000-wifi[Nano ESP32] | All digital & analog pins | link:https://docs.arduino.cc/#mkr-family[MKR Family] | All digital & analog pins |================================================================================================= From 91cd08030bb03f105f7c244dba34f9740d53974a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:30:17 +0100 Subject: [PATCH 172/184] Remove Zero, Due & MKR Family Section Remove the Zero, Due & MKR Family section --- .../analogReadResolution.adoc | 2 +- .../analogWriteResolution.adoc | 2 +- Language/Functions/Zero, Due, MKR Family/.gitkeep | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename Language/Functions/{Zero, Due, MKR Family => Analog IO}/analogReadResolution.adoc (98%) rename Language/Functions/{Zero, Due, MKR Family => Analog IO}/analogWriteResolution.adoc (99%) delete mode 100644 Language/Functions/Zero, Due, MKR Family/.gitkeep diff --git a/Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc b/Language/Functions/Analog IO/analogReadResolution.adoc similarity index 98% rename from Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc rename to Language/Functions/Analog IO/analogReadResolution.adoc index 4531306b3..8a935374e 100644 --- a/Language/Functions/Zero, Due, MKR Family/analogReadResolution.adoc +++ b/Language/Functions/Analog IO/analogReadResolution.adoc @@ -1,7 +1,7 @@ --- title: analogReadResolution() categories: [ "Functions" ] -subCategories: [ "Zero, Due & MKR Family" ] +subCategories: [ "Analog I/O" ] --- diff --git a/Language/Functions/Zero, Due, MKR Family/analogWriteResolution.adoc b/Language/Functions/Analog IO/analogWriteResolution.adoc similarity index 99% rename from Language/Functions/Zero, Due, MKR Family/analogWriteResolution.adoc rename to Language/Functions/Analog IO/analogWriteResolution.adoc index 3ef4e482f..649eb171c 100644 --- a/Language/Functions/Zero, Due, MKR Family/analogWriteResolution.adoc +++ b/Language/Functions/Analog IO/analogWriteResolution.adoc @@ -1,7 +1,7 @@ --- title: analogWriteResolution() categories: [ "Functions" ] -subCategories: [ "Zero, Due & MKR Family" ] +subCategories: [ "Analog I/O" ] --- diff --git a/Language/Functions/Zero, Due, MKR Family/.gitkeep b/Language/Functions/Zero, Due, MKR Family/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 817b23404cd48ddf3cbe110d834a738c0d1ac6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 8 Jan 2024 13:35:18 +0100 Subject: [PATCH 173/184] Update bitWrite.adoc --- Language/Functions/Bits and Bytes/bitWrite.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Bits and Bytes/bitWrite.adoc b/Language/Functions/Bits and Bytes/bitWrite.adoc index 82b4d6a55..b0e5ef723 100644 --- a/Language/Functions/Bits and Bytes/bitWrite.adoc +++ b/Language/Functions/Bits and Bytes/bitWrite.adoc @@ -17,7 +17,7 @@ subCategories: [ "Bits and Bytes" ] [float] === Description -Writes to a bit of a variable, e.g. `bool`, `int`, `long`. Note that `float` & `double` are not supported. You can write to a bit of variables up to an `unsigned long` (32 bits / 8 bytes). +Writes to a bit of a variable, e.g. `bool`, `int`, `long`. Note that `float` & `double` are not supported. You can write to a bit of variables up to an `unsigned long` (32 bits / 4 bytes). [%hardbreaks] From c3a7f9e4ad6b63809e80dc3cbf7197624eb1e9f3 Mon Sep 17 00:00:00 2001 From: justbennett <28458839+justbennett@users.noreply.github.com> Date: Tue, 9 Jan 2024 15:36:43 -0600 Subject: [PATCH 174/184] Update SPI.adoc Fix table cells out of alignment and remove unnecessary cells. --- Language/Functions/Communication/SPI.adoc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index d99d60d29..d05c6f468 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -31,16 +31,16 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le [#howtouse] -- |================================================================================================================================================ -| Boards | Default SPI Pins | Additonal SPI Pins | Notes | -| UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header | -| UNO R4 Minima, UNO R4 WiFi| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header | -| Leonardo, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header | -| Micro | 14(CIPO), 15(SCK), 16(COPI) | | +| Boards | Default SPI Pins | Additonal SPI Pins | Notes +| UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header +| UNO R4 Minima, UNO R4 WiFi| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header +| Leonardo, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header +| Micro | 14(CIPO), 15(SCK), 16(COPI) | | | Nano boards | 11(COPI), 12(CIPO), 13(SCK) | | | MKR boards | 8(COPI), 9(SCK), 10(CIPO) | | -| Due | 74(CIPO), 75(MOSI), 76(SCK) | SPI pins available on dedicated SPI header | | -| GIGA R1 WiFi | 89(CIPO), 90(COPI), 91(SCK) | 12(CIPO), 11(COPI), 13(SCK), 10(CS) | Note that pin 89,90,91 are located on the SPI header | -| Mega 2560 Rev3 | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | | SPI pins available on ICSP header | +| Due | 74(CIPO), 75(MOSI), 76(SCK) | SPI pins available on dedicated SPI header | +| GIGA R1 WiFi | 89(CIPO), 90(COPI), 91(SCK) | 12(CIPO), 11(COPI), 13(SCK), 10(CS) | Note that pin 89,90,91 are located on the SPI header +| Mega 2560 Rev3 | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | | SPI pins available on ICSP header |================================================================================================================================================ -- From 90b1ee21779d9e477b1809f112a47f16307c5045 Mon Sep 17 00:00:00 2001 From: Michael Cheich <52792043+ProgrammingElectronics@users.noreply.github.com> Date: Wed, 31 Jan 2024 13:19:22 -0500 Subject: [PATCH 175/184] Update switchCase.adoc Corrected grammar in sentence by adding the verb "use" to the sentence. --- Language/Structure/Control Structure/switchCase.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Structure/Control Structure/switchCase.adoc b/Language/Structure/Control Structure/switchCase.adoc index e608c23d2..bfad7fa89 100644 --- a/Language/Structure/Control Structure/switchCase.adoc +++ b/Language/Structure/Control Structure/switchCase.adoc @@ -49,7 +49,7 @@ switch (var) { *You can also use the `bool` data type when you just two switch cases. -Note that you can also negative values as input. +Note that you can also use negative values as input. [float] === Returns From 56228e96993073afb3f700b0dd0910f673bfc5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:34:14 +0100 Subject: [PATCH 176/184] Initial changes (not complete) --- Language/Functions/Communication/Serial.adoc | 29 ++++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Language/Functions/Communication/Serial.adoc b/Language/Functions/Communication/Serial.adoc index 2342f7251..c99f01c80 100644 --- a/Language/Functions/Communication/Serial.adoc +++ b/Language/Functions/Communication/Serial.adoc @@ -17,20 +17,25 @@ Used for communication between the Arduino board and a computer or other devices [options="header"] |================================================================================================================================================ -| Board | Serial pins | Serial1 pins | Serial2 pins | Serial3 pins -| UNO R3, UNO R3 SMD Mini | 0(RX), 1(TX) | | | -| UNO R4 Minima, UNO R4 WiFi| 18(RX), 17(TX) | | | -| Leonardo, Micro, Yún Rev2 | 0(RX), 1(TX) | | | -| Uno WiFi Rev.2 | 0(RX), 1(TX) | | | -| 101 | 0(RX), 1(TX) | | | -| MKR boards | 13(RX), 14(TX) | | | -| Nano boards | 0(RX), 1(TX) | | | -| Zero | 0(RX), 1(TX) | | | -| Due | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) -| GIGA R1 WiFi | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) -| Mega 2560 Rev3 | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) +| Board | Serial pins | Serial1 pins | Serial2 pins | Serial3 pins | Serial4 pins +| UNO R3, UNO R3 SMD Mini | 0(RX), 1(TX) | | | | +| Nano (classic) | 0(RX), 1(TX) | | | | +| UNO R4 Minima, UNO R4 WiFi| | 0(RX0), 1(TX0) | | | +| Leonardo, Micro, Yún Rev2 | | 0(RX), 1(TX) | | | +| Uno WiFi Rev.2 | | 0(RX), 1(TX) | | | +| MKR boards | | 13(RX), 14(TX) | | | +| Zero | | 0(RX), 1(TX) | | | +| GIGA R1 WiFi | | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) +| Due | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) | +| Mega 2560 Rev3 | 0(RX), 1(TX) | 19(RX1), 18(TX1) | 17(RX2), 16(TX2) | 15(RX3), 14(TX3) | +| Nano 33 IoT | | 0(RX0), 1(TX0) | | | +| Nano RP2040 Connect | | 0(RX0), 1(TX0) | | | +| Nano BLE / BLE Sense | | 0(RX0), 1(TX0) | | | +| Nano ESP32 | | 0(RX0), 1(TX0) | Any free GPIO [1] | | |================================================================================================================================================ +* [1] The Nano ESP32 has a second hardware serial port available, but you need to specify the pins. + On older boards (Uno, Nano, Mini, and Mega), pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board. [%hardbreaks] From d8162eae49f686956c8bf96a860ef0ef91ab1693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:06:56 +0100 Subject: [PATCH 177/184] Update Serial.adoc --- Language/Functions/Communication/Serial.adoc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Language/Functions/Communication/Serial.adoc b/Language/Functions/Communication/Serial.adoc index c99f01c80..0d9bf7efd 100644 --- a/Language/Functions/Communication/Serial.adoc +++ b/Language/Functions/Communication/Serial.adoc @@ -31,9 +31,19 @@ Used for communication between the Arduino board and a computer or other devices | Nano 33 IoT | | 0(RX0), 1(TX0) | | | | Nano RP2040 Connect | | 0(RX0), 1(TX0) | | | | Nano BLE / BLE Sense | | 0(RX0), 1(TX0) | | | -| Nano ESP32 | | 0(RX0), 1(TX0) | Any free GPIO [1] | | |================================================================================================================================================ + +[options="header"] + +The Nano ESP32 board + +|================================================================================================================================================ +| Board | Serial0 pins | Serial1 pins | Serial2 pins | Serial3 pins | Serial4 pins +| Nano ESP32 | | 0(RX0), 1(TX0) | Any free GPIO [1] | | +|================================================================================================================================================ + + * [1] The Nano ESP32 has a second hardware serial port available, but you need to specify the pins. From f5d20ad2f1d9d95a35c87bdbb8e36e0a31650bc2 Mon Sep 17 00:00:00 2001 From: Owain Williams Date: Mon, 12 Feb 2024 23:53:03 +0000 Subject: [PATCH 178/184] Add word 'specify' to entries in parameter descriptions --- Language/Structure/Control Structure/switchCase.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Structure/Control Structure/switchCase.adoc b/Language/Structure/Control Structure/switchCase.adoc index bfad7fa89..a10f6304e 100644 --- a/Language/Structure/Control Structure/switchCase.adoc +++ b/Language/Structure/Control Structure/switchCase.adoc @@ -47,7 +47,7 @@ switch (var) { `var`: an *integer* variable whose value to compare with various cases. Any integer data type is allowed*, such as `byte`, `char`, `int`, `long`. `label1`, `label2`: constants. Any integer data type here is also allowed. -*You can also use the `bool` data type when you just two switch cases. +*You can also use the `bool` data type when you specify just two switch cases. Note that you can also use negative values as input. From 826653711d331a1a400dd6b810b867f54b76157a Mon Sep 17 00:00:00 2001 From: Owain Williams Date: Mon, 12 Feb 2024 23:59:36 +0000 Subject: [PATCH 179/184] Add space between single line comment begin and comment text In order to remain consistent with other code examples --- Language/Structure/Control Structure/switchCase.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Structure/Control Structure/switchCase.adoc b/Language/Structure/Control Structure/switchCase.adoc index a10f6304e..246bcc2c0 100644 --- a/Language/Structure/Control Structure/switchCase.adoc +++ b/Language/Structure/Control Structure/switchCase.adoc @@ -72,10 +72,10 @@ Nothing ---- switch (var) { case 1: - //do something when var equals 1 + // do something when var equals 1 break; case 2: - //do something when var equals 2 + // do something when var equals 2 break; default: // if nothing else matches, do the default From 79e593c38459964447d9647093798a8581add08a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:31:56 +0100 Subject: [PATCH 180/184] Update Serial.adoc --- Language/Functions/Communication/Serial.adoc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Language/Functions/Communication/Serial.adoc b/Language/Functions/Communication/Serial.adoc index 0d9bf7efd..9b47ddbff 100644 --- a/Language/Functions/Communication/Serial.adoc +++ b/Language/Functions/Communication/Serial.adoc @@ -36,17 +36,16 @@ Used for communication between the Arduino board and a computer or other devices [options="header"] -The Nano ESP32 board +The Nano ESP32 board is an exception due to being based on the ESP32 core. Here, `Serial0` refers to `RX0` and `TX0`, while `Serial1` and `Serial2` are additional ports that can be assigned to any free GPIO. |================================================================================================================================================ -| Board | Serial0 pins | Serial1 pins | Serial2 pins | Serial3 pins | Serial4 pins -| Nano ESP32 | | 0(RX0), 1(TX0) | Any free GPIO [1] | | +| Board | Serial0 pins | Serial1 pins | Serial2 pins | Serial3 pins | Serial4 pins +| Nano ESP32 | 0(RX0), 1(TX0) | Any free GPIO | Any free GPIO | | |================================================================================================================================================ +You can read more about configuring the Nano ESP32's additional serial ports in https://docs.arduino.cc/tutorials/nano-esp32/cheat-sheet/#uart[this article]. -* [1] The Nano ESP32 has a second hardware serial port available, but you need to specify the pins. - - +[%hardbreaks] On older boards (Uno, Nano, Mini, and Mega), pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board. [%hardbreaks] You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to `begin()`. From e0246cae2a8de5ddcff7e941dc88defdf13ee53d Mon Sep 17 00:00:00 2001 From: drf5n Date: Thu, 15 Feb 2024 12:44:07 -0500 Subject: [PATCH 181/184] Update highLow.adoc Change the 0/1 order to match the HIGH/LOW & true/false order in the beginning of the sentence. --- Language/Variables/Constants/highLow.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Language/Variables/Constants/highLow.adoc b/Language/Variables/Constants/highLow.adoc index f7d84a9ae..1bec2b54e 100644 --- a/Language/Variables/Constants/highLow.adoc +++ b/Language/Variables/Constants/highLow.adoc @@ -12,7 +12,7 @@ subCategories: [ "Constants" ] [float] == Defining Pin Levels: HIGH and LOW -When reading or writing to a digital pin there are only two possible values a pin can take/be-set-to: `HIGH` and `LOW`. These are the same as `true` and `false`, as well as `0` and `1`. +When reading or writing to a digital pin there are only two possible values a pin can take/be-set-to: `HIGH` and `LOW`. These are the same as `true` and `false`, as well as `1` and `0`. [float] === HIGH @@ -58,4 +58,4 @@ When a pin is configured to OUTPUT with pinMode(), and set to LOW with digitalWr [role="language"] -- -// SEE ALSO SECTION ENDS \ No newline at end of file +// SEE ALSO SECTION ENDS From f9f157ba3318b881e9944cf2f9da97b980d7d47d Mon Sep 17 00:00:00 2001 From: jbarchuk Date: Sun, 18 Feb 2024 13:02:27 -0500 Subject: [PATCH 182/184] Update analogWrite.adoc Format detail. --- Language/Functions/Analog IO/analogWrite.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Functions/Analog IO/analogWrite.adoc b/Language/Functions/Analog IO/analogWrite.adoc index d6337046a..36894922e 100644 --- a/Language/Functions/Analog IO/analogWrite.adoc +++ b/Language/Functions/Analog IO/analogWrite.adoc @@ -40,7 +40,7 @@ Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. C +*+ These pins are officially supported PWM pins. While some boards have additional pins capable of PWM, using them is recommended only for advanced users that can account for timer availability and potential conflicts with other uses of those pins. + +**+ In addition to PWM capabilities on the pins noted above, the MKR, Nano 33 IoT, Zero and UNO R4 boards have true analog output when using `analogWrite()` on the `DAC0` (`A0`) pin. + -+***+ In addition to PWM capabilities on the pins noted above, the Due and GIGA R1 boards have true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. ++***+ In addition to PWM capabilities on the pins noted above, the Due and GIGA R1 boards have true analog output when using `analogWrite()` on pins `DAC0` and `DAC1`. + +****+ Only 4 different pins can be used at the same time. Enabling PWM on more than 4 pins will abort the running sketch and require resetting the board to upload a new sketch again. + [%hardbreaks] From f2fd28490a3fe3bf55d10ba93080add39fd3c977 Mon Sep 17 00:00:00 2001 From: Mateus Alves <98139059+redyf@users.noreply.github.com> Date: Sat, 8 Jun 2024 20:40:10 -0300 Subject: [PATCH 183/184] Fix typos (#984) * fix: typos in AsciiDoc_sample * fix: typo in Serial Directory * fix: typo in Wire directory * fix: typos in Communication directory * fix: typo in mouseMove.adoc * fix: typo in switchCase.adoc file * fix: typo in array.adoc file * fix: typo in LICENSE file MERCHANTIBILITY -> MERCHANTABILITY --- .../AsciiDoc_Template-Parent_Of_Entities.adoc | 2 +- .../Reference_Terms/AsciiDoc_Template-Single_Entity.adoc | 2 +- LICENSE.md | 2 +- Language/Functions/Communication/Print.adoc | 4 ++-- Language/Functions/Communication/SPI.adoc | 2 +- Language/Functions/Communication/Serial/print.adoc | 2 +- Language/Functions/Communication/Wire.adoc | 2 +- .../Functions/Communication/Wire/getWireTimeoutFlag.adoc | 4 ++-- Language/Functions/Communication/Wire/setWireTimeout.adoc | 8 ++++---- Language/Functions/USB/Mouse/mouseMove.adoc | 2 +- Language/Structure/Control Structure/switchCase.adoc | 2 +- Language/Variables/Data Types/array.adoc | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Parent_Of_Entities.adoc b/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Parent_Of_Entities.adoc index c0c06e710..4fdc98960 100644 --- a/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Parent_Of_Entities.adoc +++ b/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Parent_Of_Entities.adoc @@ -85,7 +85,7 @@ http://arduino.cc[serialEvent()] [role="language"] // Whenever you want to link to another Reference term, or more in general to a relative link, -// use the syntax shown below. Please note that the file format is subsituted by attribute. +// use the syntax shown below. Please note that the file format is substituted by attribute. // Please note that you always need to replace spaces that you might find in folder/file names with %20 // The entire link to Reference pages must be lower case, regardless of the case of the folders and files in this repository. * #LANGUAGE# link:../AsciiDoc_Template-Single_Entity[Single Entity] diff --git a/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Single_Entity.adoc b/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Single_Entity.adoc index aa4f95051..a9e23d242 100644 --- a/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Single_Entity.adoc +++ b/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Single_Entity.adoc @@ -110,7 +110,7 @@ image::http://arduino.cc/en/uploads/Main/ArduinoUno_R3_Front_450px.jpg[caption=" [role="language"] // Whenever you want to link to another Reference term, or more in general to a relative link, -// use the syntax shown below. Please note that the file format is subsituted by attribute. +// use the syntax shown below. Please note that the file format is substituted by attribute. // Please note that you always need to replace spaces that you might find in folder/file names with %20 // The entire link to Reference pages must be lower case, regardless of the case of the folders and files in this repository. // For language tag, items will be automatically generated for any other item of the same subcategory, diff --git a/LICENSE.md b/LICENSE.md index c90487cb0..53764dac4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -264,7 +264,7 @@ subject to and limited by the following restrictions: UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, -INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION diff --git a/Language/Functions/Communication/Print.adoc b/Language/Functions/Communication/Print.adoc index 31b61ba5d..b1c5497b3 100644 --- a/Language/Functions/Communication/Print.adoc +++ b/Language/Functions/Communication/Print.adoc @@ -18,7 +18,7 @@ subCategories: [ "Communication" ] === Description The Print class is an abstract base class that provides a common interface for printing data to different output devices. It defines several methods that allow printing data in different formats. -Print class is related to several libraries in Arduino that use the printing funcionality to interact with devices such as Serial Monitor, LCD Screen, printers, etc. +Print class is related to several libraries in Arduino that use the printing functionality to interact with devices such as Serial Monitor, LCD Screen, printers, etc. Some of the libraries that use the Print class are: @@ -58,4 +58,4 @@ link:https://www.arduino.cc/reference/en/language/functions/communication/serial === See also -- -// SEE ALSO SECTION ENDS \ No newline at end of file +// SEE ALSO SECTION ENDS diff --git a/Language/Functions/Communication/SPI.adoc b/Language/Functions/Communication/SPI.adoc index d05c6f468..a448778cf 100644 --- a/Language/Functions/Communication/SPI.adoc +++ b/Language/Functions/Communication/SPI.adoc @@ -31,7 +31,7 @@ To read more about Arduino and SPI, you can visit the https://docs.arduino.cc/le [#howtouse] -- |================================================================================================================================================ -| Boards | Default SPI Pins | Additonal SPI Pins | Notes +| Boards | Default SPI Pins | Additional SPI Pins | Notes | UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini Ltd| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header | UNO R4 Minima, UNO R4 WiFi| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header | Leonardo, Yún Rev2, Zero| 10(CS), 11(COPI), 12(CIPO), 13(SCK) | | SPI pins available on ICSP header diff --git a/Language/Functions/Communication/Serial/print.adoc b/Language/Functions/Communication/Serial/print.adoc index a14c9cec1..e228bdf1e 100644 --- a/Language/Functions/Communication/Serial/print.adoc +++ b/Language/Functions/Communication/Serial/print.adoc @@ -100,7 +100,7 @@ void loop() { for (int x = 0; x < 64; x++) { // only part of the ASCII chart, change to suit // print it out in many formats: Serial.print(x); // print as an ASCII-encoded decimal - same as "DEC" - Serial.print("\t\t"); // prints two tabs to accomodate the label length + Serial.print("\t\t"); // prints two tabs to accommodate the label length Serial.print(x, DEC); // print as an ASCII-encoded decimal Serial.print("\t"); // prints a tab diff --git a/Language/Functions/Communication/Wire.adoc b/Language/Functions/Communication/Wire.adoc index 4aed17dc7..50ee777b7 100644 --- a/Language/Functions/Communication/Wire.adoc +++ b/Language/Functions/Communication/Wire.adoc @@ -16,7 +16,7 @@ subCategories: [ "Communication" ] === Description -This library allows you to communicate with I2C devices, a feature that is present on all Arduino boards. I2C is a very common protocol, primarly used for reading/sending data to/from external I2C components. To learn more, visit link:https://docs.arduino.cc/learn/communication/wire[this article for Arduino & I2C]. +This library allows you to communicate with I2C devices, a feature that is present on all Arduino boards. I2C is a very common protocol, primarily used for reading/sending data to/from external I2C components. To learn more, visit link:https://docs.arduino.cc/learn/communication/wire[this article for Arduino & I2C]. Due to the hardware design and various architectural differences, the I2C pins are located in different places. The pin map just below highlights the default pins, as well as additional ports available on certain boards. diff --git a/Language/Functions/Communication/Wire/getWireTimeoutFlag.adoc b/Language/Functions/Communication/Wire/getWireTimeoutFlag.adoc index 25c5301d2..c50449a63 100644 --- a/Language/Functions/Communication/Wire/getWireTimeoutFlag.adoc +++ b/Language/Functions/Communication/Wire/getWireTimeoutFlag.adoc @@ -10,7 +10,7 @@ title: getWireTimeoutFlag() [float] === Description -Checks whether a timeout has occured since the last time the flag was cleared. +Checks whether a timeout has occurred since the last time the flag was cleared. This flag is set is set whenever a timeout occurs and cleared when `Wire.clearWireTimeoutFlag()` is called, or when the timeout is changed using `Wire.setWireTimeout()`. @@ -34,4 +34,4 @@ This function was not available in the original version of the Wire library and -- -//OVERVIEW SECTION ENDS \ No newline at end of file +//OVERVIEW SECTION ENDS diff --git a/Language/Functions/Communication/Wire/setWireTimeout.adoc b/Language/Functions/Communication/Wire/setWireTimeout.adoc index 761e6797c..3cfe18b8e 100644 --- a/Language/Functions/Communication/Wire/setWireTimeout.adoc +++ b/Language/Functions/Communication/Wire/setWireTimeout.adoc @@ -53,7 +53,7 @@ void loop() { Wire.write(123); // send command byte error = Wire.endTransmission(); // run transaction if (error) { - Serial.println("Error occured when writing"); + Serial.println("Error occurred when writing"); if (error == 5) Serial.println("It was a timeout"); } @@ -66,7 +66,7 @@ void loop() { #endif byte len = Wire.requestFrom(8, 1); // request 1 byte from device #8 if (len == 0) { - Serial.println("Error occured when reading"); + Serial.println("Error occurred when reading"); #if defined(WIRE_HAS_TIMEOUT) if (Wire.getWireTimeoutFlag()) Serial.println("It was a timeout"); @@ -88,7 +88,7 @@ If `reset_on_timeout` was set to true and the platform supports this, the Wire h When a timeout is triggered, a flag is set that can be queried with `getWireTimeoutFlag()` and must be cleared manually using `clearWireTimeoutFlag()` (and is also cleared when `setWireTimeout()` is called). -Note that this timeout can also trigger while waiting for clock stretching or waiting for a second master to complete its transaction. So make sure to adapt the timeout to accomodate for those cases if needed. A typical timeout would be 25ms (which is the maximum clock stretching allowed by the SMBus protocol), but (much) shorter values will usually also work. +Note that this timeout can also trigger while waiting for clock stretching or waiting for a second master to complete its transaction. So make sure to adapt the timeout to accommodate for those cases if needed. A typical timeout would be 25ms (which is the maximum clock stretching allowed by the SMBus protocol), but (much) shorter values will usually also work. [float] @@ -102,4 +102,4 @@ If you require the timeout to be disabled, it is recommended you disable it by d -- -//OVERVIEW SECTION ENDS \ No newline at end of file +//OVERVIEW SECTION ENDS diff --git a/Language/Functions/USB/Mouse/mouseMove.adoc b/Language/Functions/USB/Mouse/mouseMove.adoc index 852938b29..f4214f85a 100644 --- a/Language/Functions/USB/Mouse/mouseMove.adoc +++ b/Language/Functions/USB/Mouse/mouseMove.adoc @@ -110,7 +110,7 @@ int readAxis(int axisNumber) { } // the Y axis needs to be inverted in order to - // map the movemment correctly: + // map the movement correctly: if (axisNumber == 1) { distance = -distance; } diff --git a/Language/Structure/Control Structure/switchCase.adoc b/Language/Structure/Control Structure/switchCase.adoc index 246bcc2c0..7b2fad04d 100644 --- a/Language/Structure/Control Structure/switchCase.adoc +++ b/Language/Structure/Control Structure/switchCase.adoc @@ -92,7 +92,7 @@ switch (var) { -// SEE ALSO SECTIN BEGINS +// SEE ALSO SECTION BEGINS [#see_also] -- diff --git a/Language/Variables/Data Types/array.adoc b/Language/Variables/Data Types/array.adoc index 1825020c8..d9b781b61 100644 --- a/Language/Variables/Data Types/array.adoc +++ b/Language/Variables/Data Types/array.adoc @@ -22,7 +22,7 @@ All of the methods below are valid ways to create (declare) an array. // Declare an array of a given length without initializing the values: int myInts[6]; - // Declare an array without explicitely choosing a size (the compiler + // Declare an array without explicitly choosing a size (the compiler // counts the elements and creates an array of the appropriate size): int myPins[] = {2, 4, 8, 3, 6, 4}; From 386ea64ec278e3f6df3002b08a0ee64454549c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20M=C3=A9ndez?= <49886387+mcmchris@users.noreply.github.com> Date: Tue, 1 Apr 2025 15:45:45 -0400 Subject: [PATCH 184/184] Broken Links fix --- Language/Functions/Communication/Print.adoc | 6 +++--- Language/Functions/Communication/Serial/available.adoc | 2 +- .../Functions/Communication/Serial/availableForWrite.adoc | 2 +- Language/Functions/Communication/Serial/begin.adoc | 4 ++-- Language/Functions/Communication/Serial/end.adoc | 2 +- Language/Functions/Communication/Serial/find.adoc | 2 +- Language/Functions/Communication/Serial/findUntil.adoc | 2 +- Language/Functions/Communication/Serial/flush.adoc | 2 +- Language/Functions/Communication/Serial/parseFloat.adoc | 2 +- Language/Functions/Communication/Serial/parseInt.adoc | 2 +- Language/Functions/Communication/Serial/peek.adoc | 2 +- Language/Functions/Communication/Serial/print.adoc | 2 +- Language/Functions/Communication/Serial/println.adoc | 2 +- Language/Functions/Communication/Serial/read.adoc | 2 +- Language/Functions/Communication/Serial/readBytes.adoc | 2 +- Language/Functions/Communication/Serial/readBytesUntil.adoc | 2 +- Language/Functions/Communication/Serial/readString.adoc | 4 ++-- .../Functions/Communication/Serial/readStringUntil.adoc | 4 ++-- Language/Functions/Communication/Serial/setTimeout.adoc | 2 +- Language/Functions/Communication/Serial/write.adoc | 2 +- Language/Functions/Communication/stream.adoc | 4 ++-- 21 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Language/Functions/Communication/Print.adoc b/Language/Functions/Communication/Print.adoc index b1c5497b3..a6b7a142d 100644 --- a/Language/Functions/Communication/Print.adoc +++ b/Language/Functions/Communication/Print.adoc @@ -22,7 +22,7 @@ Print class is related to several libraries in Arduino that use the printing fun Some of the libraries that use the Print class are: -* link:../serial[Serial] +* link:https://www.arduino.cc/en/Reference/serial[Serial] * link:https://reference.arduino.cc/reference/en/libraries/liquidcrystal/[LiquidCrystal] * link:https://www.arduino.cc/en/Reference/Ethernet[Ethernet] * link:https://reference.arduino.cc/reference/en/libraries/wifi/wificlient/[Wifi] @@ -41,8 +41,8 @@ Some of the libraries that use the Print class are: [float] === Functions link:https://www.arduino.cc/reference/en/language/functions/communication/wire/write/[write()] + -link:https://www.arduino.cc/reference/en/language/functions/communication/serial/print/[print()] + -link:https://www.arduino.cc/reference/en/language/functions/communication/serial/println/[println()] +link:https://www.arduino.cc/en/Reference/serial/print/[print()] + +link:https://www.arduino.cc/en/Reference/serial/println/[println()] ''' diff --git a/Language/Functions/Communication/Serial/available.adoc b/Language/Functions/Communication/Serial/available.adoc index 4c6d7a60f..14b8ab166 100644 --- a/Language/Functions/Communication/Serial/available.adoc +++ b/Language/Functions/Communication/Serial/available.adoc @@ -24,7 +24,7 @@ Get the number of bytes (characters) available for reading from the serial port. [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. [float] diff --git a/Language/Functions/Communication/Serial/availableForWrite.adoc b/Language/Functions/Communication/Serial/availableForWrite.adoc index 9989dfb66..fe76f5407 100644 --- a/Language/Functions/Communication/Serial/availableForWrite.adoc +++ b/Language/Functions/Communication/Serial/availableForWrite.adoc @@ -25,7 +25,7 @@ Get the number of bytes (characters) available for writing in the serial buffer [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. [float] diff --git a/Language/Functions/Communication/Serial/begin.adoc b/Language/Functions/Communication/Serial/begin.adoc index ea8c0f04e..ed0bf8270 100644 --- a/Language/Functions/Communication/Serial/begin.adoc +++ b/Language/Functions/Communication/Serial/begin.adoc @@ -28,7 +28,7 @@ An optional second argument configures the data, parity, and stop bits. The defa [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `speed`: in bits per second (baud). Allowed data types: `long`. + `config`: sets data, parity, and stop bits. Valid values are: + `SERIAL_5N1` + @@ -112,7 +112,7 @@ Thanks to Jeff Gray for the mega example [float] === Notes and Warnings -For USB CDC serial ports (e.g. `Serial` on the Leonardo), `Serial.begin()` is irrelevant. You can use any baud rate and configuration for serial communication with these ports. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +For USB CDC serial ports (e.g. `Serial` on the Leonardo), `Serial.begin()` is irrelevant. You can use any baud rate and configuration for serial communication with these ports. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. The only `config` value supported for `Serial1` on the Arduino Nano 33 BLE and Nano 33 BLE Sense boards is `SERIAL_8N1`. [%hardbreaks] diff --git a/Language/Functions/Communication/Serial/end.adoc b/Language/Functions/Communication/Serial/end.adoc index b13b78ff5..a3b101c79 100644 --- a/Language/Functions/Communication/Serial/end.adoc +++ b/Language/Functions/Communication/Serial/end.adoc @@ -25,7 +25,7 @@ Disables serial communication, allowing the RX and TX pins to be used for genera [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. [float] diff --git a/Language/Functions/Communication/Serial/find.adoc b/Language/Functions/Communication/Serial/find.adoc index b36efdc63..9f454de0a 100644 --- a/Language/Functions/Communication/Serial/find.adoc +++ b/Language/Functions/Communication/Serial/find.adoc @@ -28,7 +28,7 @@ title: Serial.find() [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `target`: the string to search for. Allowed data types: `char`. + `length`: length of the target. Allowed data types: `size_t`. diff --git a/Language/Functions/Communication/Serial/findUntil.adoc b/Language/Functions/Communication/Serial/findUntil.adoc index f19bfa6ef..a2e9fc0d6 100644 --- a/Language/Functions/Communication/Serial/findUntil.adoc +++ b/Language/Functions/Communication/Serial/findUntil.adoc @@ -29,7 +29,7 @@ The function returns true if the target string is found, false if it times out. [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `target`: the string to search for. Allowed data types: `char`. + `terminal`: the terminal string in the search. Allowed data types: `char`. diff --git a/Language/Functions/Communication/Serial/flush.adoc b/Language/Functions/Communication/Serial/flush.adoc index 03a0b6819..fb7027f6a 100644 --- a/Language/Functions/Communication/Serial/flush.adoc +++ b/Language/Functions/Communication/Serial/flush.adoc @@ -27,7 +27,7 @@ Waits for the transmission of outgoing serial data to complete. [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. [float] diff --git a/Language/Functions/Communication/Serial/parseFloat.adoc b/Language/Functions/Communication/Serial/parseFloat.adoc index b9b0cde79..6c1f01bcd 100644 --- a/Language/Functions/Communication/Serial/parseFloat.adoc +++ b/Language/Functions/Communication/Serial/parseFloat.adoc @@ -29,7 +29,7 @@ title: Serial.parseFloat() [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `lookahead`: the mode used to look ahead in the stream for a floating point number. Allowed data types: `LookaheadMode`. Allowed `lookahead` values: * `SKIP_ALL`: all characters other than a minus sign, decimal point, or digits are ignored when scanning the stream for a floating point number. This is the default mode. diff --git a/Language/Functions/Communication/Serial/parseInt.adoc b/Language/Functions/Communication/Serial/parseInt.adoc index 962b48cbd..93c6e1563 100644 --- a/Language/Functions/Communication/Serial/parseInt.adoc +++ b/Language/Functions/Communication/Serial/parseInt.adoc @@ -35,7 +35,7 @@ In particular: [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `lookahead`: the mode used to look ahead in the stream for an integer. Allowed data types: `LookaheadMode`. Allowed `lookahead` values: * `SKIP_ALL`: all characters other than digits or a minus sign are ignored when scanning the stream for an integer. This is the default mode. diff --git a/Language/Functions/Communication/Serial/peek.adoc b/Language/Functions/Communication/Serial/peek.adoc index 7209996be..557c729af 100644 --- a/Language/Functions/Communication/Serial/peek.adoc +++ b/Language/Functions/Communication/Serial/peek.adoc @@ -27,7 +27,7 @@ Returns the next byte (character) of incoming serial data without removing it fr [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. [float] diff --git a/Language/Functions/Communication/Serial/print.adoc b/Language/Functions/Communication/Serial/print.adoc index e228bdf1e..8f09302a0 100644 --- a/Language/Functions/Communication/Serial/print.adoc +++ b/Language/Functions/Communication/Serial/print.adoc @@ -48,7 +48,7 @@ To send data without conversion to its representation as characters, use link:.. [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `val`: the value to print. Allowed data types: any data type. diff --git a/Language/Functions/Communication/Serial/println.adoc b/Language/Functions/Communication/Serial/println.adoc index 15ef923c0..49dc2aaa1 100644 --- a/Language/Functions/Communication/Serial/println.adoc +++ b/Language/Functions/Communication/Serial/println.adoc @@ -26,7 +26,7 @@ Prints data to the serial port as human-readable ASCII text followed by a carria [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `val`: the value to print. Allowed data types: any data type. + `format`: specifies the number base (for integral data types) or number of decimal places (for floating point types). diff --git a/Language/Functions/Communication/Serial/read.adoc b/Language/Functions/Communication/Serial/read.adoc index 2a781fc7e..b721f2322 100644 --- a/Language/Functions/Communication/Serial/read.adoc +++ b/Language/Functions/Communication/Serial/read.adoc @@ -27,7 +27,7 @@ Reads incoming serial data. [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. [float] diff --git a/Language/Functions/Communication/Serial/readBytes.adoc b/Language/Functions/Communication/Serial/readBytes.adoc index da566d64b..eee28340b 100644 --- a/Language/Functions/Communication/Serial/readBytes.adoc +++ b/Language/Functions/Communication/Serial/readBytes.adoc @@ -29,7 +29,7 @@ title: Serial.readBytes() [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `buffer`: the buffer to store the bytes in. Allowed data types: array of `char` or `byte`. + `length`: the number of bytes to read. Allowed data types: `int`. diff --git a/Language/Functions/Communication/Serial/readBytesUntil.adoc b/Language/Functions/Communication/Serial/readBytesUntil.adoc index d35ff46c2..50775c471 100644 --- a/Language/Functions/Communication/Serial/readBytesUntil.adoc +++ b/Language/Functions/Communication/Serial/readBytesUntil.adoc @@ -29,7 +29,7 @@ Serial.readBytesUntil() reads characters from the serial buffer into an array. T [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `character`: the character to search for. Allowed data types: `char`. + `buffer`: the buffer to store the bytes in. Allowed data types: array of `char` or `byte`. + `length`: the number of bytes to read. Allowed data types: `int`. diff --git a/Language/Functions/Communication/Serial/readString.adoc b/Language/Functions/Communication/Serial/readString.adoc index c0fa8856c..496787c8e 100644 --- a/Language/Functions/Communication/Serial/readString.adoc +++ b/Language/Functions/Communication/Serial/readString.adoc @@ -27,7 +27,7 @@ title: Serial.readString() [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. [float] @@ -85,7 +85,7 @@ The function does not terminate early if the data contains end of line character === See also [role="language"] -* #LANGUAGE# link:../../serial[Serial] +* #LANGUAGE# link:https://www.arduino.cc/en/Reference/serial[Serial] * #LANGUAGE# link:../begin[begin()] * #LANGUAGE# link:../end[end()] * #LANGUAGE# link:../available[available()] diff --git a/Language/Functions/Communication/Serial/readStringUntil.adoc b/Language/Functions/Communication/Serial/readStringUntil.adoc index 5a699bfc2..54f24540f 100644 --- a/Language/Functions/Communication/Serial/readStringUntil.adoc +++ b/Language/Functions/Communication/Serial/readStringUntil.adoc @@ -27,7 +27,7 @@ title: Serial.readStringUntil() [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `terminator`: the character to search for. Allowed data types: `char`. @@ -62,7 +62,7 @@ If the terminator character can't be found, all read characters will be discarde === See also [role="language"] -* #LANGUAGE# link:../../serial[Serial] +* #LANGUAGE# link:https://www.arduino.cc/en/Reference/serial[Serial] * #LANGUAGE# link:../begin[begin()] * #LANGUAGE# link:../end[end()] * #LANGUAGE# link:../available[available()] diff --git a/Language/Functions/Communication/Serial/setTimeout.adoc b/Language/Functions/Communication/Serial/setTimeout.adoc index 76e73dff1..41d5f224c 100644 --- a/Language/Functions/Communication/Serial/setTimeout.adoc +++ b/Language/Functions/Communication/Serial/setTimeout.adoc @@ -27,7 +27,7 @@ title: Serial.setTimeout() [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `time`: timeout duration in milliseconds. Allowed data types: `long`. diff --git a/Language/Functions/Communication/Serial/write.adoc b/Language/Functions/Communication/Serial/write.adoc index 00f0bdc66..cfcd0b944 100644 --- a/Language/Functions/Communication/Serial/write.adoc +++ b/Language/Functions/Communication/Serial/write.adoc @@ -24,7 +24,7 @@ Writes binary data to the serial port. This data is sent as a byte or series of [float] === Parameters -`_Serial_`: serial port object. See the list of available serial ports for each board on the link:../../serial[Serial main page]. + +`_Serial_`: serial port object. See the list of available serial ports for each board on the link:https://www.arduino.cc/en/Reference/serial[Serial main page]. + `val`: a value to send as a single byte. + `str`: a string to send as a series of bytes. + `buf`: an array to send as a series of bytes. + diff --git a/Language/Functions/Communication/stream.adoc b/Language/Functions/Communication/stream.adoc index 8950da800..7258a219e 100644 --- a/Language/Functions/Communication/stream.adoc +++ b/Language/Functions/Communication/stream.adoc @@ -22,8 +22,8 @@ Stream defines the reading functions in Arduino. When using any core functionali Some of the libraries that rely on Stream include : -* link:../serial[Serial] -* link:https://www.arduino.cc/en/Reference/Wire[Wire] +* link:https://www.arduino.cc/en/Reference/serial[Serial] +* link:https://www.arduino.cc/en/Reference/wire[Wire] * link:https://www.arduino.cc/en/Reference/Ethernet[Ethernet] * link:https://www.arduino.cc/en/Reference/SD[SD]