diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..e608f4e --- /dev/null +++ b/.clang-format @@ -0,0 +1,190 @@ +# Source: https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration +--- +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignConsecutiveMacros: None +AlignEscapedNewlines: DontAlign +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLambdasOnASingleLine: Empty +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: No +AttributeMacros: + - __capability +BasedOnStyle: LLVM +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterJavaFieldAnnotations: false +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Attach +BreakBeforeConceptDeclarations: false +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakConstructorInitializersBeforeComma: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: false +ColumnLimit: 0 +CommentPragmas: '' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DeriveLineEnding: true +DerivePointerAlignment: true +DisableFormat: false +EmptyLineAfterAccessModifier: Leave +EmptyLineBeforeAccessModifier: Leave +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: true +IndentCaseLabels: true +IndentExternBlock: Indent +IndentGotoLabels: false +IndentPPDirectives: None +IndentRequires: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +LambdaBodyIndentation: Signature +Language: Cpp +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 100000 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PPIndentWidth: -1 +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 1 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 1 +PenaltyBreakFirstLessLess: 1 +PenaltyBreakOpenParenthesis: 1 +PenaltyBreakString: 1 +PenaltyBreakTemplateDeclaration: 1 +PenaltyExcessCharacter: 1 +PenaltyIndentedWhitespace: 1 +PenaltyReturnTypeOnItsOwnLine: 1 +PointerAlignment: Right +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: false +RemoveBracesLLVM: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 0 +SortIncludes: Never +SortJavaStaticImport: Before +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Leave +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInLineCommentPrefix: + Minimum: 0 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 2 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE + - NS_SWIFT_NAME + - CF_SWIFT_NAME diff --git a/.github/workflows/code-formatting-check.yml b/.github/workflows/code-formatting-check.yml index 351099b..5406dae 100644 --- a/.github/workflows/code-formatting-check.yml +++ b/.github/workflows/code-formatting-check.yml @@ -4,10 +4,14 @@ on: pull_request: paths: - ".github/workflows/code-formatting-check.yml" + - ".clang-format" + - "examples_formatter.sh" - "examples/**" push: paths: - ".github/workflows/code-formatting-check.yml" + - ".clang-format" + - "examples_formatter.sh" - "examples/**" jobs: @@ -15,49 +19,43 @@ jobs: runs-on: ubuntu-latest env: - # See: https://sourceforge.net/projects/astyle/files/astyle/ - ASTYLE_VERSION: 3.1 + # See: https://github.com/arduino/arduino-ide/blob/main/arduino-ide-extension/package.json + CLANG_FORMAT_VERSION: 14.0.0 steps: + - name: Set environment variables + run: | + # See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable + echo "CLANG_FORMAT_INSTALL_PATH=${{ runner.temp }}/clang-format" >> "$GITHUB_ENV" + - name: Checkout uses: actions/checkout@v3 - # See: http://astyle.sourceforge.net/ - - name: Download Artistic Style - uses: carlosperate/download-file-action@v1 + - name: Download ClangFormat + id: download + uses: MrOctopus/download-asset-action@1.0 with: - file-url: https://iweb.dl.sourceforge.net/project/astyle/astyle/astyle%20${{ env.ASTYLE_VERSION }}/astyle_${{ env.ASTYLE_VERSION }}_linux.tar.gz - location: ${{ runner.temp }}/astyle + repository: arduino/clang-static-binaries + tag: ${{ env.CLANG_FORMAT_VERSION }} + asset: clang-format_${{ env.CLANG_FORMAT_VERSION }}_Linux_64bit.tar.bz2 + target: ${{ env.CLANG_FORMAT_INSTALL_PATH }} - # See: http://astyle.sourceforge.net/install.html#_GCC_Makefile - - name: Build Artistic Style + - name: Install ClangFormat run: | - # Build Artistic Style - cd "${{ runner.temp }}/astyle" - tar --extract --file="astyle_${{ env.ASTYLE_VERSION }}_linux.tar.gz" - cd "astyle/build/gcc" - make - - # GITHUB_WORKSPACE - - name: Check code formatting + cd "${{ env.CLANG_FORMAT_INSTALL_PATH }}" + tar --extract --file="${{ steps.download.outputs.name }}" + # Add installation to PATH: + # See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path + echo "${{ env.CLANG_FORMAT_INSTALL_PATH }}/clang_Linux_64bit" >> "$GITHUB_PATH" + + - name: Format examples + run: ./examples_formatter.sh + + - name: Check formatting run: | - # Check code formatting of example sketches - # Don't exit on first formatting check fail - set +e - # Set default exit status - EXIT_STATUS=0 - while read -r filePath; do - # Check if it's a file (find matches on pruned folders) - if [[ -f "$filePath" ]]; then - if ! diff --strip-trailing-cr "$filePath" <("${{ runner.temp }}/astyle/astyle/build/gcc/bin/astyle" --options="${GITHUB_WORKSPACE}/examples_formatter.conf" --dry-run <"$filePath"); then - echo "ERROR: Non-compliant code formatting in $filePath" - EXIT_STATUS=1 - fi - fi - done <<<"$(find "${GITHUB_WORKSPACE}/examples" -regextype posix-extended \( -regex '.*\.((ino)|(h)|(cpp)|(c))$' -and -type f \))" - if [[ "$EXIT_STATUS" != "0" ]]; then + if ! git diff --color --exit-code; then echo "Please do an Auto Format on the sketches:" echo "Arduino IDE: Tools > Auto Format" echo "Arduino Web Editor: Ctrl + B" + exit 1 fi - exit "$EXIT_STATUS" diff --git a/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino b/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino index 10e67ec..d1dd321 100644 --- a/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino +++ b/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino @@ -22,5 +22,5 @@ void loop() { int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); - delay(1); // delay in between reads for stability + delay(1); // delay in between reads for stability } diff --git a/examples/01.Basics/BareMinimum/BareMinimum.ino b/examples/01.Basics/BareMinimum/BareMinimum.ino index 95c2b6e..ab62321 100644 --- a/examples/01.Basics/BareMinimum/BareMinimum.ino +++ b/examples/01.Basics/BareMinimum/BareMinimum.ino @@ -1,9 +1,7 @@ void setup() { // put your setup code here, to run once: - } void loop() { // put your main code here, to run repeatedly: - } diff --git a/examples/01.Basics/Blink/Blink.ino b/examples/01.Basics/Blink/Blink.ino index 9abb8f5..9f8b472 100644 --- a/examples/01.Basics/Blink/Blink.ino +++ b/examples/01.Basics/Blink/Blink.ino @@ -30,8 +30,8 @@ void setup() { // the loop function runs over and over again forever void loop() { - digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) - delay(1000); // wait for a second - digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW - delay(1000); // wait for a second + digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + delay(1000); // wait for a second + digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + delay(1000); // wait for a second } diff --git a/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino b/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino index 49389fe..3456f2f 100644 --- a/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino +++ b/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino @@ -25,5 +25,5 @@ void loop() { int buttonState = digitalRead(pushButton); // print out the state of the button: Serial.println(buttonState); - delay(1); // delay in between reads for stability + delay(1); // delay in between reads for stability } diff --git a/examples/01.Basics/Fade/Fade.ino b/examples/01.Basics/Fade/Fade.ino index e598b03..4637979 100644 --- a/examples/01.Basics/Fade/Fade.ino +++ b/examples/01.Basics/Fade/Fade.ino @@ -13,9 +13,9 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fade */ -int led = 9; // the PWM pin the LED is attached to -int brightness = 0; // how bright the LED is -int fadeAmount = 5; // how many points to fade the LED by +int led = 9; // the PWM pin the LED is attached to +int brightness = 0; // how bright the LED is +int fadeAmount = 5; // how many points to fade the LED by // the setup routine runs once when you press reset: void setup() { diff --git a/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino b/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino index ac47087..d266349 100644 --- a/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino +++ b/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino @@ -29,17 +29,17 @@ */ // constants won't change. Used here to set a pin number: -const int ledPin = LED_BUILTIN;// the number of the LED pin +const int ledPin = LED_BUILTIN; // the number of the LED pin // Variables will change: -int ledState = LOW; // ledState used to set the LED +int ledState = LOW; // ledState used to set the LED // Generally, you should use "unsigned long" for variables that hold time // The value will quickly become too large for an int to store -unsigned long previousMillis = 0; // will store last time LED was updated +unsigned long previousMillis = 0; // will store last time LED was updated // constants won't change: -const long interval = 1000; // interval at which to blink (milliseconds) +const long interval = 1000; // interval at which to blink (milliseconds) void setup() { // set the digital pin as output: diff --git a/examples/02.Digital/Button/Button.ino b/examples/02.Digital/Button/Button.ino index 7732bc8..e041c31 100644 --- a/examples/02.Digital/Button/Button.ino +++ b/examples/02.Digital/Button/Button.ino @@ -23,11 +23,11 @@ */ // constants won't change. They're used here to set pin numbers: -const int buttonPin = 2; // the number of the pushbutton pin -const int ledPin = 13; // the number of the LED pin +const int buttonPin = 2; // the number of the pushbutton pin +const int ledPin = 13; // the number of the LED pin // variables will change: -int buttonState = 0; // variable for reading the pushbutton status +int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: diff --git a/examples/02.Digital/Debounce/Debounce.ino b/examples/02.Digital/Debounce/Debounce.ino index 42cd1dc..6460d90 100644 --- a/examples/02.Digital/Debounce/Debounce.ino +++ b/examples/02.Digital/Debounce/Debounce.ino @@ -28,13 +28,13 @@ */ // constants won't change. They're used here to set pin numbers: -const int buttonPin = 2; // the number of the pushbutton pin -const int ledPin = 13; // the number of the LED pin +const int buttonPin = 2; // the number of the pushbutton pin +const int ledPin = 13; // the number of the LED pin // Variables will change: -int ledState = HIGH; // the current state of the output pin -int buttonState; // the current reading from the input pin -int lastButtonState = LOW; // the previous reading from the input pin +int ledState = HIGH; // the current state of the output pin +int buttonState; // the current reading from the input pin +int lastButtonState = LOW; // the previous reading from the input pin // the following variables are unsigned longs because the time, measured in // milliseconds, will quickly become a bigger number than can be stored in an int. diff --git a/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino b/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino index 16863a0..0f0eea1 100644 --- a/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino +++ b/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino @@ -26,7 +26,6 @@ void setup() { //configure pin 2 as an input and enable the internal pull-up resistor pinMode(2, INPUT_PULLUP); pinMode(13, OUTPUT); - } void loop() { diff --git a/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino b/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino index d3b2122..5205e17 100644 --- a/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino +++ b/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino @@ -25,13 +25,13 @@ */ // this constant won't change: -const int buttonPin = 2; // the pin that the pushbutton is attached to -const int ledPin = 13; // the pin that the LED is attached to +const int buttonPin = 2; // the pin that the pushbutton is attached to +const int ledPin = 13; // the pin that the LED is attached to // Variables will change: -int buttonPushCounter = 0; // counter for the number of button presses -int buttonState = 0; // current state of the button -int lastButtonState = 0; // previous state of the button +int buttonPushCounter = 0; // counter for the number of button presses +int buttonState = 0; // current state of the button +int lastButtonState = 0; // previous state of the button void setup() { // initialize the button pin as a input: @@ -75,5 +75,4 @@ void loop() { } else { digitalWrite(ledPin, LOW); } - } diff --git a/examples/02.Digital/toneKeyboard/pitches.h b/examples/02.Digital/toneKeyboard/pitches.h index 70b06bc..a0d69ac 100644 --- a/examples/02.Digital/toneKeyboard/pitches.h +++ b/examples/02.Digital/toneKeyboard/pitches.h @@ -2,94 +2,92 @@ Public Constants *************************************************/ -#define NOTE_B0 31 -#define NOTE_C1 33 +#define NOTE_B0 31 +#define NOTE_C1 33 #define NOTE_CS1 35 -#define NOTE_D1 37 +#define NOTE_D1 37 #define NOTE_DS1 39 -#define NOTE_E1 41 -#define NOTE_F1 44 +#define NOTE_E1 41 +#define NOTE_F1 44 #define NOTE_FS1 46 -#define NOTE_G1 49 +#define NOTE_G1 49 #define NOTE_GS1 52 -#define NOTE_A1 55 +#define NOTE_A1 55 #define NOTE_AS1 58 -#define NOTE_B1 62 -#define NOTE_C2 65 +#define NOTE_B1 62 +#define NOTE_C2 65 #define NOTE_CS2 69 -#define NOTE_D2 73 +#define NOTE_D2 73 #define NOTE_DS2 78 -#define NOTE_E2 82 -#define NOTE_F2 87 +#define NOTE_E2 82 +#define NOTE_F2 87 #define NOTE_FS2 93 -#define NOTE_G2 98 +#define NOTE_G2 98 #define NOTE_GS2 104 -#define NOTE_A2 110 +#define NOTE_A2 110 #define NOTE_AS2 117 -#define NOTE_B2 123 -#define NOTE_C3 131 +#define NOTE_B2 123 +#define NOTE_C3 131 #define NOTE_CS3 139 -#define NOTE_D3 147 +#define NOTE_D3 147 #define NOTE_DS3 156 -#define NOTE_E3 165 -#define NOTE_F3 175 +#define NOTE_E3 165 +#define NOTE_F3 175 #define NOTE_FS3 185 -#define NOTE_G3 196 +#define NOTE_G3 196 #define NOTE_GS3 208 -#define NOTE_A3 220 +#define NOTE_A3 220 #define NOTE_AS3 233 -#define NOTE_B3 247 -#define NOTE_C4 262 +#define NOTE_B3 247 +#define NOTE_C4 262 #define NOTE_CS4 277 -#define NOTE_D4 294 +#define NOTE_D4 294 #define NOTE_DS4 311 -#define NOTE_E4 330 -#define NOTE_F4 349 +#define NOTE_E4 330 +#define NOTE_F4 349 #define NOTE_FS4 370 -#define NOTE_G4 392 +#define NOTE_G4 392 #define NOTE_GS4 415 -#define NOTE_A4 440 +#define NOTE_A4 440 #define NOTE_AS4 466 -#define NOTE_B4 494 -#define NOTE_C5 523 +#define NOTE_B4 494 +#define NOTE_C5 523 #define NOTE_CS5 554 -#define NOTE_D5 587 +#define NOTE_D5 587 #define NOTE_DS5 622 -#define NOTE_E5 659 -#define NOTE_F5 698 +#define NOTE_E5 659 +#define NOTE_F5 698 #define NOTE_FS5 740 -#define NOTE_G5 784 +#define NOTE_G5 784 #define NOTE_GS5 831 -#define NOTE_A5 880 +#define NOTE_A5 880 #define NOTE_AS5 932 -#define NOTE_B5 988 -#define NOTE_C6 1047 +#define NOTE_B5 988 +#define NOTE_C6 1047 #define NOTE_CS6 1109 -#define NOTE_D6 1175 +#define NOTE_D6 1175 #define NOTE_DS6 1245 -#define NOTE_E6 1319 -#define NOTE_F6 1397 +#define NOTE_E6 1319 +#define NOTE_F6 1397 #define NOTE_FS6 1480 -#define NOTE_G6 1568 +#define NOTE_G6 1568 #define NOTE_GS6 1661 -#define NOTE_A6 1760 +#define NOTE_A6 1760 #define NOTE_AS6 1865 -#define NOTE_B6 1976 -#define NOTE_C7 2093 +#define NOTE_B6 1976 +#define NOTE_C7 2093 #define NOTE_CS7 2217 -#define NOTE_D7 2349 +#define NOTE_D7 2349 #define NOTE_DS7 2489 -#define NOTE_E7 2637 -#define NOTE_F7 2794 +#define NOTE_E7 2637 +#define NOTE_F7 2794 #define NOTE_FS7 2960 -#define NOTE_G7 3136 +#define NOTE_G7 3136 #define NOTE_GS7 3322 -#define NOTE_A7 3520 +#define NOTE_A7 3520 #define NOTE_AS7 3729 -#define NOTE_B7 3951 -#define NOTE_C8 4186 +#define NOTE_B7 3951 +#define NOTE_C8 4186 #define NOTE_CS8 4435 -#define NOTE_D8 4699 +#define NOTE_D8 4699 #define NOTE_DS8 4978 - - diff --git a/examples/02.Digital/toneKeyboard/toneKeyboard.ino b/examples/02.Digital/toneKeyboard/toneKeyboard.ino index 99e1cc5..c8e73c6 100644 --- a/examples/02.Digital/toneKeyboard/toneKeyboard.ino +++ b/examples/02.Digital/toneKeyboard/toneKeyboard.ino @@ -19,7 +19,7 @@ #include "pitches.h" -const int threshold = 10; // minimum reading of the sensors that generates a note +const int threshold = 10; // minimum reading of the sensors that generates a note // notes to play, corresponding to the 3 sensors: int notes[] = { @@ -27,7 +27,6 @@ int notes[] = { }; void setup() { - } void loop() { diff --git a/examples/02.Digital/toneMelody/pitches.h b/examples/02.Digital/toneMelody/pitches.h index 70b06bc..a0d69ac 100644 --- a/examples/02.Digital/toneMelody/pitches.h +++ b/examples/02.Digital/toneMelody/pitches.h @@ -2,94 +2,92 @@ Public Constants *************************************************/ -#define NOTE_B0 31 -#define NOTE_C1 33 +#define NOTE_B0 31 +#define NOTE_C1 33 #define NOTE_CS1 35 -#define NOTE_D1 37 +#define NOTE_D1 37 #define NOTE_DS1 39 -#define NOTE_E1 41 -#define NOTE_F1 44 +#define NOTE_E1 41 +#define NOTE_F1 44 #define NOTE_FS1 46 -#define NOTE_G1 49 +#define NOTE_G1 49 #define NOTE_GS1 52 -#define NOTE_A1 55 +#define NOTE_A1 55 #define NOTE_AS1 58 -#define NOTE_B1 62 -#define NOTE_C2 65 +#define NOTE_B1 62 +#define NOTE_C2 65 #define NOTE_CS2 69 -#define NOTE_D2 73 +#define NOTE_D2 73 #define NOTE_DS2 78 -#define NOTE_E2 82 -#define NOTE_F2 87 +#define NOTE_E2 82 +#define NOTE_F2 87 #define NOTE_FS2 93 -#define NOTE_G2 98 +#define NOTE_G2 98 #define NOTE_GS2 104 -#define NOTE_A2 110 +#define NOTE_A2 110 #define NOTE_AS2 117 -#define NOTE_B2 123 -#define NOTE_C3 131 +#define NOTE_B2 123 +#define NOTE_C3 131 #define NOTE_CS3 139 -#define NOTE_D3 147 +#define NOTE_D3 147 #define NOTE_DS3 156 -#define NOTE_E3 165 -#define NOTE_F3 175 +#define NOTE_E3 165 +#define NOTE_F3 175 #define NOTE_FS3 185 -#define NOTE_G3 196 +#define NOTE_G3 196 #define NOTE_GS3 208 -#define NOTE_A3 220 +#define NOTE_A3 220 #define NOTE_AS3 233 -#define NOTE_B3 247 -#define NOTE_C4 262 +#define NOTE_B3 247 +#define NOTE_C4 262 #define NOTE_CS4 277 -#define NOTE_D4 294 +#define NOTE_D4 294 #define NOTE_DS4 311 -#define NOTE_E4 330 -#define NOTE_F4 349 +#define NOTE_E4 330 +#define NOTE_F4 349 #define NOTE_FS4 370 -#define NOTE_G4 392 +#define NOTE_G4 392 #define NOTE_GS4 415 -#define NOTE_A4 440 +#define NOTE_A4 440 #define NOTE_AS4 466 -#define NOTE_B4 494 -#define NOTE_C5 523 +#define NOTE_B4 494 +#define NOTE_C5 523 #define NOTE_CS5 554 -#define NOTE_D5 587 +#define NOTE_D5 587 #define NOTE_DS5 622 -#define NOTE_E5 659 -#define NOTE_F5 698 +#define NOTE_E5 659 +#define NOTE_F5 698 #define NOTE_FS5 740 -#define NOTE_G5 784 +#define NOTE_G5 784 #define NOTE_GS5 831 -#define NOTE_A5 880 +#define NOTE_A5 880 #define NOTE_AS5 932 -#define NOTE_B5 988 -#define NOTE_C6 1047 +#define NOTE_B5 988 +#define NOTE_C6 1047 #define NOTE_CS6 1109 -#define NOTE_D6 1175 +#define NOTE_D6 1175 #define NOTE_DS6 1245 -#define NOTE_E6 1319 -#define NOTE_F6 1397 +#define NOTE_E6 1319 +#define NOTE_F6 1397 #define NOTE_FS6 1480 -#define NOTE_G6 1568 +#define NOTE_G6 1568 #define NOTE_GS6 1661 -#define NOTE_A6 1760 +#define NOTE_A6 1760 #define NOTE_AS6 1865 -#define NOTE_B6 1976 -#define NOTE_C7 2093 +#define NOTE_B6 1976 +#define NOTE_C7 2093 #define NOTE_CS7 2217 -#define NOTE_D7 2349 +#define NOTE_D7 2349 #define NOTE_DS7 2489 -#define NOTE_E7 2637 -#define NOTE_F7 2794 +#define NOTE_E7 2637 +#define NOTE_F7 2794 #define NOTE_FS7 2960 -#define NOTE_G7 3136 +#define NOTE_G7 3136 #define NOTE_GS7 3322 -#define NOTE_A7 3520 +#define NOTE_A7 3520 #define NOTE_AS7 3729 -#define NOTE_B7 3951 -#define NOTE_C8 4186 +#define NOTE_B7 3951 +#define NOTE_C8 4186 #define NOTE_CS8 4435 -#define NOTE_D8 4699 +#define NOTE_D8 4699 #define NOTE_DS8 4978 - - diff --git a/examples/02.Digital/toneMultiple/toneMultiple.ino b/examples/02.Digital/toneMultiple/toneMultiple.ino index 63a6020..8d97fa7 100644 --- a/examples/02.Digital/toneMultiple/toneMultiple.ino +++ b/examples/02.Digital/toneMultiple/toneMultiple.ino @@ -16,7 +16,6 @@ */ void setup() { - } void loop() { diff --git a/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino b/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino index 3171cfc..592f671 100644 --- a/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino +++ b/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino @@ -35,5 +35,5 @@ void loop() { // play the pitch: tone(9, thisPitch, 10); - delay(1); // delay in between reads for stability + delay(1); // delay in between reads for stability } diff --git a/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino b/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino index 4033ca0..851342d 100644 --- a/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino +++ b/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino @@ -22,10 +22,10 @@ // These constants won't change. They're used to give names to the pins used: const int analogInPin = A0; // Analog input pin that the potentiometer is attached to -const int analogOutPin = 9; // Analog output pin that the LED is attached to +const int analogOutPin = 9; // Analog output pin that the LED is attached to -int sensorValue = 0; // value read from the pot -int outputValue = 0; // value output to the PWM (analog out) +int sensorValue = 0; // value read from the pot +int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: diff --git a/examples/03.Analog/AnalogInput/AnalogInput.ino b/examples/03.Analog/AnalogInput/AnalogInput.ino index 9a1bbdd..735a8b5 100644 --- a/examples/03.Analog/AnalogInput/AnalogInput.ino +++ b/examples/03.Analog/AnalogInput/AnalogInput.ino @@ -27,7 +27,7 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogInput */ -int sensorPin = A0; // select the input pin for the potentiometer +int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor diff --git a/examples/03.Analog/Calibration/Calibration.ino b/examples/03.Analog/Calibration/Calibration.ino index ba5cf70..e0f639b 100644 --- a/examples/03.Analog/Calibration/Calibration.ino +++ b/examples/03.Analog/Calibration/Calibration.ino @@ -27,13 +27,13 @@ */ // These constants won't change: -const int sensorPin = A0; // pin that the sensor is attached to -const int ledPin = 9; // pin that the LED is attached to +const int sensorPin = A0; // pin that the sensor is attached to +const int ledPin = 9; // pin that the LED is attached to // variables: -int sensorValue = 0; // the sensor value -int sensorMin = 1023; // minimum sensor value -int sensorMax = 0; // maximum sensor value +int sensorValue = 0; // the sensor value +int sensorMin = 1023; // minimum sensor value +int sensorMax = 0; // maximum sensor value void setup() { diff --git a/examples/03.Analog/Fading/Fading.ino b/examples/03.Analog/Fading/Fading.ino index da694e5..7923546 100644 --- a/examples/03.Analog/Fading/Fading.ino +++ b/examples/03.Analog/Fading/Fading.ino @@ -16,7 +16,7 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fading */ -int ledPin = 9; // LED connected to digital pin 9 +int ledPin = 9; // LED connected to digital pin 9 void setup() { // nothing happens in setup @@ -24,7 +24,7 @@ void setup() { void loop() { // fade in from min to max in increments of 5 points: - for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) { + for (int fadeValue = 0; fadeValue <= 255; fadeValue += 5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // wait for 30 milliseconds to see the dimming effect @@ -32,7 +32,7 @@ void loop() { } // fade out from max to min in increments of 5 points: - for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) { + for (int fadeValue = 255; fadeValue >= 0; fadeValue -= 5) { // sets the value (range from 0 to 255): analogWrite(ledPin, fadeValue); // wait for 30 milliseconds to see the dimming effect diff --git a/examples/03.Analog/Smoothing/Smoothing.ino b/examples/03.Analog/Smoothing/Smoothing.ino index eece339..15c0f1a 100644 --- a/examples/03.Analog/Smoothing/Smoothing.ino +++ b/examples/03.Analog/Smoothing/Smoothing.ino @@ -24,10 +24,10 @@ // value to determine the size of the readings array. const int numReadings = 10; -int readings[numReadings]; // the readings from the analog input -int readIndex = 0; // the index of the current reading -int total = 0; // the running total -int average = 0; // the average +int readings[numReadings]; // the readings from the analog input +int readIndex = 0; // the index of the current reading +int total = 0; // the running total +int average = 0; // the average int inputPin = A0; @@ -60,5 +60,5 @@ void loop() { average = total / numReadings; // send it to the computer as ASCII digits Serial.println(average); - delay(1); // delay in between reads for stability + delay(1); // delay in between reads for stability } diff --git a/examples/04.Communication/ASCIITable/ASCIITable.ino b/examples/04.Communication/ASCIITable/ASCIITable.ino index f3d4bd0..f7fc4d4 100644 --- a/examples/04.Communication/ASCIITable/ASCIITable.ino +++ b/examples/04.Communication/ASCIITable/ASCIITable.ino @@ -23,7 +23,7 @@ void setup() { //Initialize serial and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } // prints title with ending line break @@ -66,7 +66,7 @@ void loop() { Serial.println(thisByte, BIN); // if printed last visible character '~' or 126, stop: - if (thisByte == 126) { // you could also use if (thisByte == '~') { + if (thisByte == 126) { // you could also use if (thisByte == '~') { // This loop loops forever and does nothing while (true) { continue; diff --git a/examples/04.Communication/Dimmer/Dimmer.ino b/examples/04.Communication/Dimmer/Dimmer.ino index fc121a0..2f82344 100644 --- a/examples/04.Communication/Dimmer/Dimmer.ino +++ b/examples/04.Communication/Dimmer/Dimmer.ino @@ -20,7 +20,7 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/Dimmer */ -const int ledPin = 9; // the pin that the LED is attached to +const int ledPin = 9; // the pin that the LED is attached to void setup() { // initialize the serial communication: diff --git a/examples/04.Communication/Midi/Midi.ino b/examples/04.Communication/Midi/Midi.ino index 851fa9b..0602bf0 100644 --- a/examples/04.Communication/Midi/Midi.ino +++ b/examples/04.Communication/Midi/Midi.ino @@ -27,7 +27,7 @@ void setup() { void loop() { // play notes from F#-0 (0x1E) to F#-5 (0x5A): - for (int note = 0x1E; note < 0x5A; note ++) { + for (int note = 0x1E; note < 0x5A; note++) { //Note on channel 1 (0x90), some note value (note), middle velocity (0x45): noteOn(0x90, note, 0x45); delay(100); diff --git a/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino b/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino index 1582118..cff02ef 100644 --- a/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino +++ b/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino @@ -21,8 +21,8 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/PhysicalPixel */ -const int ledPin = 13; // the pin that the LED is attached to -int incomingByte; // a variable to read incoming serial data into +const int ledPin = 13; // the pin that the LED is attached to +int incomingByte; // a variable to read incoming serial data into void setup() { // initialize serial communication: diff --git a/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino b/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino index bbd395b..1cab997 100644 --- a/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino +++ b/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino @@ -33,7 +33,6 @@ void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); - } void loop() { diff --git a/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino b/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino index 6fb0a60..b778774 100644 --- a/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino +++ b/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino @@ -21,16 +21,16 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/SerialCallResponse */ -int firstSensor = 0; // first analog sensor -int secondSensor = 0; // second analog sensor -int thirdSensor = 0; // digital sensor -int inByte = 0; // incoming serial byte +int firstSensor = 0; // first analog sensor +int secondSensor = 0; // second analog sensor +int thirdSensor = 0; // digital sensor +int inByte = 0; // incoming serial byte void setup() { // start serial port at 9600 bps: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } pinMode(2, INPUT); // digital sensor is on digital pin 2 @@ -59,7 +59,7 @@ void loop() { void establishContact() { while (Serial.available() <= 0) { - Serial.print('A'); // send a capital A + Serial.print('A'); // send a capital A delay(300); } } diff --git a/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino b/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino index 44b2155..e5b02cd 100644 --- a/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino +++ b/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino @@ -22,16 +22,16 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/SerialCallResponseASCII */ -int firstSensor = 0; // first analog sensor -int secondSensor = 0; // second analog sensor -int thirdSensor = 0; // digital sensor -int inByte = 0; // incoming serial byte +int firstSensor = 0; // first analog sensor +int secondSensor = 0; // second analog sensor +int thirdSensor = 0; // digital sensor +int inByte = 0; // incoming serial byte void setup() { // start serial port at 9600 bps and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } @@ -61,7 +61,7 @@ void loop() { void establishContact() { while (Serial.available() <= 0) { - Serial.println("0,0,0"); // send an initial string + Serial.println("0,0,0"); // send an initial string delay(300); } } diff --git a/examples/04.Communication/SerialEvent/SerialEvent.ino b/examples/04.Communication/SerialEvent/SerialEvent.ino index 831b98d..13c5630 100644 --- a/examples/04.Communication/SerialEvent/SerialEvent.ino +++ b/examples/04.Communication/SerialEvent/SerialEvent.ino @@ -18,7 +18,7 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/SerialEvent */ -String inputString = ""; // a String to hold incoming data +String inputString = ""; // a String to hold incoming data bool stringComplete = false; // whether the string is complete void setup() { diff --git a/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino b/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino index 84824cf..8f46bbe 100644 --- a/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino +++ b/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino @@ -30,11 +30,11 @@ void setup() { } void loop() { - if (Serial.available()) { // If anything comes in Serial (USB), - Serial1.write(Serial.read()); // read it and send it out Serial1 (pins 0 & 1) + if (Serial.available()) { // If anything comes in Serial (USB), + Serial1.write(Serial.read()); // read it and send it out Serial1 (pins 0 & 1) } - if (Serial1.available()) { // If anything comes in Serial1 (pins 0 & 1) - Serial.write(Serial1.read()); // read it and send it out Serial (USB) + if (Serial1.available()) { // If anything comes in Serial1 (pins 0 & 1) + Serial.write(Serial1.read()); // read it and send it out Serial (USB) } } diff --git a/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino b/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino index cf66348..6ffd934 100644 --- a/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino +++ b/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino @@ -16,9 +16,9 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/VirtualColorMixer */ -const int redPin = A0; // sensor to control red color -const int greenPin = A1; // sensor to control green color -const int bluePin = A2; // sensor to control blue color +const int redPin = A0; // sensor to control red color +const int greenPin = A1; // sensor to control green color +const int bluePin = A2; // sensor to control blue color void setup() { Serial.begin(9600); diff --git a/examples/05.Control/Arrays/Arrays.ino b/examples/05.Control/Arrays/Arrays.ino index dbbb4b4..75d59ee 100644 --- a/examples/05.Control/Arrays/Arrays.ino +++ b/examples/05.Control/Arrays/Arrays.ino @@ -20,11 +20,11 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/Arrays */ -int timer = 100; // The higher the number, the slower the timing. +int timer = 100; // The higher the number, the slower the timing. int ledPins[] = { 2, 7, 4, 6, 5, 3 -}; // an array of pin numbers to which LEDs are attached -int pinCount = 6; // the number of pins (i.e. the length of the array) +}; // an array of pin numbers to which LEDs are attached +int pinCount = 6; // the number of pins (i.e. the length of the array) void setup() { // the array elements are numbered from 0 to (pinCount - 1). @@ -42,7 +42,6 @@ void loop() { delay(timer); // turn the pin off: digitalWrite(ledPins[thisPin], LOW); - } // loop from the highest pin to the lowest: diff --git a/examples/05.Control/ForLoopIteration/ForLoopIteration.ino b/examples/05.Control/ForLoopIteration/ForLoopIteration.ino index af9cd7d..e6b40e7 100644 --- a/examples/05.Control/ForLoopIteration/ForLoopIteration.ino +++ b/examples/05.Control/ForLoopIteration/ForLoopIteration.ino @@ -17,7 +17,7 @@ https://www.arduino.cc/en/Tutorial/BuiltInExamples/ForLoopIteration */ -int timer = 100; // The higher the number, the slower the timing. +int timer = 100; // The higher the number, the slower the timing. void setup() { // use a for loop to initialize each pin as an output: diff --git a/examples/05.Control/IfStatementConditional/IfStatementConditional.ino b/examples/05.Control/IfStatementConditional/IfStatementConditional.ino index efd233f..ac6041a 100644 --- a/examples/05.Control/IfStatementConditional/IfStatementConditional.ino +++ b/examples/05.Control/IfStatementConditional/IfStatementConditional.ino @@ -25,9 +25,9 @@ */ // These constants won't change: -const int analogPin = A0; // pin that the sensor is attached to -const int ledPin = 13; // pin that the LED is attached to -const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input +const int analogPin = A0; // pin that the sensor is attached to +const int ledPin = 13; // pin that the LED is attached to +const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input void setup() { // initialize the LED pin as an output: @@ -49,5 +49,5 @@ void loop() { // print the analog value: Serial.println(analogValue); - delay(1); // delay in between reads for stability + delay(1); // delay in between reads for stability } diff --git a/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino b/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino index a0b42e1..0a36341 100644 --- a/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino +++ b/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino @@ -29,16 +29,16 @@ // These constants won't change: -const int sensorPin = A0; // pin that the sensor is attached to -const int ledPin = 9; // pin that the LED is attached to -const int indicatorLedPin = 13; // pin that the built-in LED is attached to -const int buttonPin = 2; // pin that the button is attached to +const int sensorPin = A0; // pin that the sensor is attached to +const int ledPin = 9; // pin that the LED is attached to +const int indicatorLedPin = 13; // pin that the built-in LED is attached to +const int buttonPin = 2; // pin that the button is attached to // These variables will change: int sensorMin = 1023; // minimum sensor value int sensorMax = 0; // maximum sensor value -int sensorValue = 0; // the sensor value +int sensorValue = 0; // the sensor value void setup() { diff --git a/examples/05.Control/switchCase/switchCase.ino b/examples/05.Control/switchCase/switchCase.ino index 3ffc9f0..f964b61 100644 --- a/examples/05.Control/switchCase/switchCase.ino +++ b/examples/05.Control/switchCase/switchCase.ino @@ -23,8 +23,8 @@ // these constants won't change. They are the lowest and highest readings you // get from your sensor: -const int sensorMin = 0; // sensor minimum, discovered through experiment -const int sensorMax = 600; // sensor maximum, discovered through experiment +const int sensorMin = 0; // sensor minimum, discovered through experiment +const int sensorMax = 600; // sensor maximum, discovered through experiment void setup() { // initialize serial communication: @@ -39,18 +39,18 @@ void loop() { // do something different depending on the range value: switch (range) { - case 0: // your hand is on the sensor + case 0: // your hand is on the sensor Serial.println("dark"); break; - case 1: // your hand is close to the sensor + case 1: // your hand is close to the sensor Serial.println("dim"); break; - case 2: // your hand is a few inches from the sensor + case 2: // your hand is a few inches from the sensor Serial.println("medium"); break; - case 3: // your hand is nowhere near the sensor + case 3: // your hand is nowhere near the sensor Serial.println("bright"); break; } - delay(1); // delay in between reads for stability + delay(1); // delay in between reads for stability } diff --git a/examples/06.Sensors/ADXL3xx/ADXL3xx.ino b/examples/06.Sensors/ADXL3xx/ADXL3xx.ino index 65b579b..b9dbf64 100644 --- a/examples/06.Sensors/ADXL3xx/ADXL3xx.ino +++ b/examples/06.Sensors/ADXL3xx/ADXL3xx.ino @@ -25,11 +25,11 @@ */ // these constants describe the pins. They won't change: -const int groundpin = 18; // analog input pin 4 -- ground -const int powerpin = 19; // analog input pin 5 -- voltage -const int xpin = A3; // x-axis of the accelerometer -const int ypin = A2; // y-axis -const int zpin = A1; // z-axis (only on 3-axis models) +const int groundpin = 18; // analog input pin 4 -- ground +const int powerpin = 19; // analog input pin 5 -- voltage +const int xpin = A3; // x-axis of the accelerometer +const int ypin = A2; // y-axis +const int zpin = A1; // z-axis (only on 3-axis models) void setup() { // initialize the serial communications: diff --git a/examples/06.Sensors/Knock/Knock.ino b/examples/06.Sensors/Knock/Knock.ino index 815d721..0e21486 100644 --- a/examples/06.Sensors/Knock/Knock.ino +++ b/examples/06.Sensors/Knock/Knock.ino @@ -23,17 +23,17 @@ // these constants won't change: -const int ledPin = 13; // LED connected to digital pin 13 -const int knockSensor = A0; // the piezo is connected to analog pin 0 -const int threshold = 100; // threshold value to decide when the detected sound is a knock or not +const int ledPin = 13; // LED connected to digital pin 13 +const int knockSensor = A0; // the piezo is connected to analog pin 0 +const int threshold = 100; // threshold value to decide when the detected sound is a knock or not // these variables will change: -int sensorReading = 0; // variable to store the value read from the sensor pin -int ledState = LOW; // variable used to store the last LED status, to toggle the light +int sensorReading = 0; // variable to store the value read from the sensor pin +int ledState = LOW; // variable used to store the last LED status, to toggle the light void setup() { - pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT + pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT Serial.begin(9600); // use the serial port } diff --git a/examples/06.Sensors/Memsic2125/Memsic2125.ino b/examples/06.Sensors/Memsic2125/Memsic2125.ino index b95472b..006306b 100644 --- a/examples/06.Sensors/Memsic2125/Memsic2125.ino +++ b/examples/06.Sensors/Memsic2125/Memsic2125.ino @@ -22,8 +22,8 @@ */ // these constants won't change: -const int xPin = 2; // X output of the accelerometer -const int yPin = 3; // Y output of the accelerometer +const int xPin = 2; // X output of the accelerometer +const int yPin = 3; // Y output of the accelerometer void setup() { // initialize serial communications: diff --git a/examples/07.Display/RowColumnScanning/RowColumnScanning.ino b/examples/07.Display/RowColumnScanning/RowColumnScanning.ino index 023a5c2..0fb04c5 100644 --- a/examples/07.Display/RowColumnScanning/RowColumnScanning.ino +++ b/examples/07.Display/RowColumnScanning/RowColumnScanning.ino @@ -83,7 +83,6 @@ void readSensors() { // set the new pixel position low so that the LED will turn on in the next // screen refresh: pixels[x][y] = LOW; - } void refreshScreen() { diff --git a/examples/07.Display/barGraph/barGraph.ino b/examples/07.Display/barGraph/barGraph.ino index ab97f13..b15f840 100644 --- a/examples/07.Display/barGraph/barGraph.ino +++ b/examples/07.Display/barGraph/barGraph.ino @@ -21,12 +21,12 @@ */ // these constants won't change: -const int analogPin = A0; // the pin that the potentiometer is attached to -const int ledCount = 10; // the number of LEDs in the bar graph +const int analogPin = A0; // the pin that the potentiometer is attached to +const int ledCount = 10; // the number of LEDs in the bar graph int ledPins[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 -}; // an array of pin numbers to which LEDs are attached +}; // an array of pin numbers to which LEDs are attached void setup() { diff --git a/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino b/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino index e7a3c23..40d68a5 100644 --- a/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino +++ b/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino @@ -17,7 +17,7 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } // send an intro: diff --git a/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino b/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino index 531742b..4763acf 100644 --- a/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino +++ b/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino @@ -20,7 +20,7 @@ void setup() { // initialize serial and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } stringOne = String("You added "); @@ -33,35 +33,36 @@ void setup() { void loop() { // adding a constant integer to a String: - stringThree = stringOne + 123; - Serial.println(stringThree); // prints "You added 123" + stringThree = stringOne + 123; + Serial.println(stringThree); // prints "You added 123" // adding a constant long integer to a String: stringThree = stringOne + 123456789; - Serial.println(stringThree); // prints "You added 123456789" + Serial.println(stringThree); // prints "You added 123456789" // adding a constant character to a String: - stringThree = stringOne + 'A'; - Serial.println(stringThree); // prints "You added A" + stringThree = stringOne + 'A'; + Serial.println(stringThree); // prints "You added A" // adding a constant string to a String: - stringThree = stringOne + "abc"; - Serial.println(stringThree); // prints "You added abc" + stringThree = stringOne + "abc"; + Serial.println(stringThree); // prints "You added abc" stringThree = stringOne + stringTwo; - Serial.println(stringThree); // prints "You added this string" + Serial.println(stringThree); // prints "You added this string" // adding a variable integer to a String: int sensorValue = analogRead(A0); stringOne = "Sensor value: "; - stringThree = stringOne + sensorValue; - Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(A0) has + stringThree = stringOne + sensorValue; + Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(A0) has // adding a variable long integer to a String: stringOne = "millis() value: "; stringThree = stringOne + millis(); - Serial.println(stringThree); // prints "The millis: 345345" or whatever value millis() has + Serial.println(stringThree); // prints "The millis: 345345" or whatever value millis() has // do nothing while true: - while (true); + while (true) + ; } diff --git a/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino b/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino index b634892..4846cf4 100644 --- a/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino +++ b/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino @@ -18,7 +18,7 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } stringOne = String("Sensor "); @@ -41,11 +41,11 @@ void loop() { // adding a constant character to a String: stringOne += 'A'; - Serial.println(stringOne); // prints "Sensor value for input A" + Serial.println(stringOne); // prints "Sensor value for input A" // adding a constant integer to a String: stringOne += 0; - Serial.println(stringOne); // prints "Sensor value for input A0" + Serial.println(stringOne); // prints "Sensor value for input A0" // adding a constant string to a String: stringOne += ": "; @@ -53,7 +53,7 @@ void loop() { // adding a variable integer to a String: stringOne += analogRead(A0); - Serial.println(stringOne); // prints "Sensor value for input A0: 456" or whatever analogRead(A0) is + Serial.println(stringOne); // prints "Sensor value for input A0: 456" or whatever analogRead(A0) is Serial.println("\n\nchanging the Strings' values"); stringOne = "A long integer: "; @@ -61,12 +61,13 @@ void loop() { // adding a constant long integer to a String: stringOne += 123456789; - Serial.println(stringOne); // prints "A long integer: 123456789" + Serial.println(stringOne); // prints "A long integer: 123456789" // using concat() to add a long variable to a String: stringTwo.concat(millis()); - Serial.println(stringTwo); // prints "The millis(): 43534" or whatever the value of the millis() is + Serial.println(stringTwo); // prints "The millis(): 43534" or whatever the value of the millis() is // do nothing while true: - while (true); + while (true) + ; } diff --git a/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino b/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino index fc6ab61..52d4de8 100644 --- a/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino +++ b/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino @@ -16,7 +16,7 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } // send an intro: @@ -39,5 +39,6 @@ void loop() { // do nothing while true: - while (true); + while (true) + ; } diff --git a/examples/08.Strings/StringCharacters/StringCharacters.ino b/examples/08.Strings/StringCharacters/StringCharacters.ino index a179cfa..6c64b57 100644 --- a/examples/08.Strings/StringCharacters/StringCharacters.ino +++ b/examples/08.Strings/StringCharacters/StringCharacters.ino @@ -16,7 +16,7 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } Serial.println("\n\nString charAt() and setCharAt():"); @@ -41,5 +41,6 @@ void loop() { Serial.println(reportString); // do nothing while true: - while (true); + while (true) + ; } diff --git a/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino b/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino index aff9139..4e57469 100644 --- a/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino +++ b/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino @@ -18,7 +18,7 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } @@ -27,7 +27,6 @@ void setup() { // send an intro: Serial.println("\n\nComparing Strings:"); Serial.println(); - } void loop() { @@ -122,7 +121,6 @@ void loop() { Serial.println(stringOne + " comes before " + stringTwo); } else { Serial.println(stringOne + " comes after " + stringTwo); - } } } diff --git a/examples/08.Strings/StringConstructors/StringConstructors.ino b/examples/08.Strings/StringConstructors/StringConstructors.ino index 85d0024..36ff78a 100644 --- a/examples/08.Strings/StringConstructors/StringConstructors.ino +++ b/examples/08.Strings/StringConstructors/StringConstructors.ino @@ -16,7 +16,7 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } // send an intro: @@ -27,42 +27,42 @@ void setup() { void loop() { // using a constant String: String stringOne = "Hello String"; - Serial.println(stringOne); // prints "Hello String" + Serial.println(stringOne); // prints "Hello String" // converting a constant char into a String: - stringOne = String('a'); - Serial.println(stringOne); // prints "a" + stringOne = String('a'); + Serial.println(stringOne); // prints "a" // converting a constant string into a String object: - String stringTwo = String("This is a string"); - Serial.println(stringTwo); // prints "This is a string" + String stringTwo = String("This is a string"); + Serial.println(stringTwo); // prints "This is a string" // concatenating two strings: - stringOne = String(stringTwo + " with more"); + stringOne = String(stringTwo + " with more"); // prints "This is a string with more": Serial.println(stringOne); // using a constant integer: - stringOne = String(13); - Serial.println(stringOne); // prints "13" + stringOne = String(13); + Serial.println(stringOne); // prints "13" // using an int and a base: - stringOne = String(analogRead(A0), DEC); + stringOne = String(analogRead(A0), DEC); // prints "453" or whatever the value of analogRead(A0) is Serial.println(stringOne); // using an int and a base (hexadecimal): - stringOne = String(45, HEX); + stringOne = String(45, HEX); // prints "2d", which is the hexadecimal version of decimal 45: Serial.println(stringOne); // using an int and a base (binary) - stringOne = String(255, BIN); + stringOne = String(255, BIN); // prints "11111111" which is the binary value of 255 Serial.println(stringOne); // using a long and a base: - stringOne = String(millis(), DEC); + stringOne = String(millis(), DEC); // prints "123456" or whatever the value of millis() is: Serial.println(stringOne); @@ -75,6 +75,6 @@ void loop() { Serial.println(stringOne); // do nothing while true: - while (true); - + while (true) + ; } diff --git a/examples/08.Strings/StringIndexOf/StringIndexOf.ino b/examples/08.Strings/StringIndexOf/StringIndexOf.ino index 219f508..cf1f816 100644 --- a/examples/08.Strings/StringIndexOf/StringIndexOf.ino +++ b/examples/08.Strings/StringIndexOf/StringIndexOf.ino @@ -16,7 +16,7 @@ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only + ; // wait for serial port to connect. Needed for native USB port only } // send an intro: @@ -50,7 +50,7 @@ void loop() { int lastOpeningBracket = stringOne.lastIndexOf('<'); Serial.println("The index of the last < in the string " + stringOne + " is " + lastOpeningBracket); - int lastListItem = stringOne.lastIndexOf("