diff --git a/build/shared/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino b/build/shared/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino index 1dc462aace5..789785dcc9a 100644 --- a/build/shared/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino +++ b/build/shared/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino @@ -1,10 +1,13 @@ /* AnalogReadSerial - Reads an analog input on pin 0, prints the result to the serial monitor. - Graphical representation is available using serial plotter (Tools > Serial Plotter menu) + + Reads an analog input on pin 0, prints the result to the Serial Monitor. + Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu). Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/AnalogReadSerial */ // the setup routine runs once when you press reset: diff --git a/build/shared/examples/01.Basics/Blink/Blink.ino b/build/shared/examples/01.Basics/Blink/Blink.ino index 5a3c7a92659..b7377254259 100644 --- a/build/shared/examples/01.Basics/Blink/Blink.ino +++ b/build/shared/examples/01.Basics/Blink/Blink.ino @@ -1,25 +1,26 @@ /* Blink - Turns on an LED on for one second, then off for one second, repeatedly. - Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO + Turns an LED on for one second, then off for one second, repeatedly. + + Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED pin independent of which board is used. - If you want to know what pin the on-board LED is connected to on your Arduino model, check - the Technical Specs of your board at https://www.arduino.cc/en/Main/Products - - This example code is in the public domain. + If you want to know what pin the on-board LED is connected to on your Arduino + model, check the Technical Specs of your board at: + https://www.arduino.cc/en/Main/Products modified 8 May 2014 by Scott Fitzgerald - modified 2 Sep 2016 by Arturo Guadalupi - modified 8 Sep 2016 by Colby Newman -*/ + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/Blink +*/ // the setup function runs once when you press reset or power the board void setup() { diff --git a/build/shared/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino b/build/shared/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino index 115b4c18c51..b3040af4e69 100644 --- a/build/shared/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino +++ b/build/shared/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino @@ -1,9 +1,12 @@ /* DigitalReadSerial - Reads a digital input on pin 2, prints the result to the serial monitor - This example code is in the public domain. - */ + Reads a digital input on pin 2, prints the result to the Serial Monitor + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/DigitalReadSerial +*/ // digital pin 2 has a pushbutton attached to it. Give it a name: int pushButton = 2; @@ -24,6 +27,3 @@ void loop() { Serial.println(buttonState); delay(1); // delay in between reads for stability } - - - diff --git a/build/shared/examples/01.Basics/Fade/Fade.ino b/build/shared/examples/01.Basics/Fade/Fade.ino index 727d1484b21..744dc427799 100644 --- a/build/shared/examples/01.Basics/Fade/Fade.ino +++ b/build/shared/examples/01.Basics/Fade/Fade.ino @@ -1,17 +1,17 @@ /* - Fade + Fade - This example shows how to fade an LED on pin 9 - using the analogWrite() function. + This example shows how to fade an LED on pin 9 using the analogWrite() + function. - The analogWrite() function uses PWM, so if - you want to change the pin you're using, be - sure to use another PWM capable pin. On most - Arduino, the PWM pins are identified with - a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11. + The analogWrite() function uses PWM, so if you want to change the pin you're + using, be sure to use another PWM capable pin. On most Arduino, the PWM pins + are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11. - This example code is in the public domain. - */ + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/Fade +*/ int led = 9; // the PWM pin the LED is attached to int brightness = 0; // how bright the LED is diff --git a/build/shared/examples/01.Basics/Fade/Fade.txt b/build/shared/examples/01.Basics/Fade/Fade.txt index 32d4d28900a..d196b43fa41 100644 --- a/build/shared/examples/01.Basics/Fade/Fade.txt +++ b/build/shared/examples/01.Basics/Fade/Fade.txt @@ -1 +1 @@ -Demonstrates the use of analog output to fade an LED. \ No newline at end of file +Demonstrates the use of analogWrite() to fade an LED. \ No newline at end of file diff --git a/build/shared/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino b/build/shared/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino index 1e2e4eda83e..4473b4e185c 100644 --- a/build/shared/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino +++ b/build/shared/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino @@ -1,10 +1,13 @@ /* ReadAnalogVoltage - Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. - Graphical representation is available using serial plotter (Tools > Serial Plotter menu) + + Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor. + Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu). Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/ReadAnalogVoltage */ // the setup routine runs once when you press reset: diff --git a/build/shared/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.txt b/build/shared/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.txt index d71a63d6ade..d4838d5dc73 100644 --- a/build/shared/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.txt +++ b/build/shared/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.txt @@ -1 +1 @@ -Reads an analog input and prints the voltage to the serial monitor. \ No newline at end of file +Reads an analog input and prints the voltage to the Serial Monitor. \ No newline at end of file diff --git a/build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino b/build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino index 6b8ae577d33..c96f3baed3b 100644 --- a/build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino +++ b/build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino @@ -1,43 +1,44 @@ -/* Blink without Delay - - Turns on and off a light emitting diode (LED) connected to a digital - pin, without using the delay() function. This means that other code - can run at the same time without being interrupted by the LED code. - - The circuit: - * Use the onboard LED. - * Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO - it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to - the correct LED pin independent of which board is used. - If you want to know what pin the on-board LED is connected to on your Arduino model, check - the Technical Specs of your board at https://www.arduino.cc/en/Main/Products - - created 2005 - by David A. Mellis - modified 8 Feb 2010 - by Paul Stoffregen - modified 11 Nov 2013 - by Scott Fitzgerald - modified 9 Jan 2017 - by Arturo Guadalupi - - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay - */ - -// constants won't change. Used here to set a pin number : +/* + Blink without Delay + + Turns on and off a light emitting diode (LED) connected to a digital pin, + without using the delay() function. This means that other code can run at the + same time without being interrupted by the LED code. + + The circuit: + - Use the onboard LED. + - Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA + and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN + is set to the correct LED pin independent of which board is used. + If you want to know what pin the on-board LED is connected to on your + Arduino model, check the Technical Specs of your board at: + https://www.arduino.cc/en/Main/Products + + created 2005 + by David A. Mellis + modified 8 Feb 2010 + by Paul Stoffregen + modified 11 Nov 2013 + by Scott Fitzgerald + modified 9 Jan 2017 + by Arturo Guadalupi + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay +*/ + +// constants won't change. Used here to set a pin number: const int ledPin = LED_BUILTIN;// the number of the LED pin -// Variables will change : +// Variables will change: 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 -// constants won't change : +// constants won't change: const long interval = 1000; // interval at which to blink (milliseconds) void setup() { @@ -48,10 +49,9 @@ void setup() { void loop() { // here is where you'd put code that needs to be running all the time. - // check to see if it's time to blink the LED; that is, if the - // difference between the current time and last time you blinked - // the LED is bigger than the interval at which you want to - // blink the LED. + // check to see if it's time to blink the LED; that is, if the difference + // between the current time and last time you blinked the LED is bigger than + // the interval at which you want to blink the LED. unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= interval) { @@ -69,4 +69,3 @@ void loop() { digitalWrite(ledPin, ledState); } } - diff --git a/build/shared/examples/02.Digital/Button/Button.ino b/build/shared/examples/02.Digital/Button/Button.ino index 33cc454f484..06cb3518996 100644 --- a/build/shared/examples/02.Digital/Button/Button.ino +++ b/build/shared/examples/02.Digital/Button/Button.ino @@ -1,31 +1,28 @@ /* Button - Turns on and off a light emitting diode(LED) connected to digital - pin 13, when pressing a pushbutton attached to pin 2. + Turns on and off a light emitting diode(LED) connected to digital pin 13, + when pressing a pushbutton attached to pin 2. + The circuit: + - LED attached from pin 13 to ground + - pushbutton attached to pin 2 from +5V + - 10K resistor attached to pin 2 from ground - The circuit: - * LED attached from pin 13 to ground - * pushbutton attached to pin 2 from +5V - * 10K resistor attached to pin 2 from ground + - Note: on most Arduinos there is already an LED on the board + attached to pin 13. - * Note: on most Arduinos there is already an LED on the board - attached to pin 13. + created 2005 + by DojoDave + modified 30 Aug 2011 + by Tom Igoe + This example code is in the public domain. - created 2005 - by DojoDave - modified 30 Aug 2011 - by Tom Igoe + http://www.arduino.cc/en/Tutorial/Button +*/ - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/Button - */ - -// constants won't change. They're used here to -// set pin numbers: +// 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 @@ -43,8 +40,7 @@ void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); - // check if the pushbutton is pressed. - // if it is, the buttonState is HIGH: + // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); @@ -52,4 +48,4 @@ void loop() { // turn LED off: digitalWrite(ledPin, LOW); } -} \ No newline at end of file +} diff --git a/build/shared/examples/02.Digital/Debounce/Debounce.ino b/build/shared/examples/02.Digital/Debounce/Debounce.ino index bdf3bdeae25..d5d48c91876 100644 --- a/build/shared/examples/02.Digital/Debounce/Debounce.ino +++ b/build/shared/examples/02.Digital/Debounce/Debounce.ino @@ -1,37 +1,33 @@ /* - Debounce + Debounce - Each time the input pin goes from LOW to HIGH (e.g. because of a push-button - press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's - a minimum delay between toggles to debounce the circuit (i.e. to ignore - noise). + Each time the input pin goes from LOW to HIGH (e.g. because of a push-button + press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's a + minimum delay between toggles to debounce the circuit (i.e. to ignore noise). - The circuit: - * LED attached from pin 13 to ground - * pushbutton attached from pin 2 to +5V - * 10K resistor attached from pin 2 to ground + The circuit: + - LED attached from pin 13 to ground + - pushbutton attached from pin 2 to +5V + - 10 kilohm resistor attached from pin 2 to ground - * Note: On most Arduino boards, there is already an LED on the board - connected to pin 13, so you don't need any extra components for this example. + - Note: On most Arduino boards, there is already an LED on the board connected + to pin 13, so you don't need any extra components for this example. + created 21 Nov 2006 + by David A. Mellis + modified 30 Aug 2011 + by Limor Fried + modified 28 Dec 2012 + by Mike Walters + modified 30 Aug 2016 + by Arturo Guadalupi - created 21 November 2006 - by David A. Mellis - modified 30 Aug 2011 - by Limor Fried - modified 28 Dec 2012 - by Mike Walters - modified 30 Aug 2016 - by Arturo Guadalupi + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/Debounce +*/ - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/Debounce - */ - -// constants won't change. They're used here to -// set pin numbers: +// 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 @@ -40,8 +36,8 @@ 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 long's because the time, measured in miliseconds, -// will quickly become a bigger number than can be stored in an int. +// 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. unsigned long lastDebounceTime = 0; // the last time the output pin was toggled unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers @@ -58,8 +54,8 @@ void loop() { int reading = digitalRead(buttonPin); // check to see if you just pressed the button - // (i.e. the input went from LOW to HIGH), and you've waited - // long enough since the last press to ignore any noise: + // (i.e. the input went from LOW to HIGH), and you've waited long enough + // since the last press to ignore any noise: // If the switch changed, due to noise or pressing: if (reading != lastButtonState) { @@ -68,8 +64,8 @@ void loop() { } if ((millis() - lastDebounceTime) > debounceDelay) { - // whatever the reading is at, it's been there for longer - // than the debounce delay, so take it as the actual current state: + // whatever the reading is at, it's been there for longer than the debounce + // delay, so take it as the actual current state: // if the button state has changed: if (reading != buttonState) { @@ -85,8 +81,6 @@ void loop() { // set the LED: digitalWrite(ledPin, ledState); - // save the reading. Next time through the loop, - // it'll be the lastButtonState: + // save the reading. Next time through the loop, it'll be the lastButtonState: lastButtonState = reading; } - diff --git a/build/shared/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino b/build/shared/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino index 7d9276b407b..dc641ac71fa 100644 --- a/build/shared/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino +++ b/build/shared/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino @@ -1,30 +1,29 @@ /* - Input Pullup Serial + Input Pull-up Serial - This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a - digital input on pin 2 and prints the results to the serial monitor. + This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a digital + input on pin 2 and prints the results to the Serial Monitor. - The circuit: - * Momentary switch attached from pin 2 to ground - * Built-in LED on pin 13 + The circuit: + - momentary switch attached from pin 2 to ground + - built-in LED on pin 13 - Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal - 20K-ohm resistor is pulled to 5V. This configuration causes the input to - read HIGH when the switch is open, and LOW when it is closed. + Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal + 20K-ohm resistor is pulled to 5V. This configuration causes the input to read + HIGH when the switch is open, and LOW when it is closed. - created 14 March 2012 - by Scott Fitzgerald + created 14 Mar 2012 + by Scott Fitzgerald - http://www.arduino.cc/en/Tutorial/InputPullupSerial + This example code is in the public domain. - This example code is in the public domain - - */ + http://www.arduino.cc/en/Tutorial/InputPullupSerial +*/ void setup() { //start serial connection Serial.begin(9600); - //configure pin2 as an input and enable the internal pull-up resistor + //configure pin 2 as an input and enable the internal pull-up resistor pinMode(2, INPUT_PULLUP); pinMode(13, OUTPUT); @@ -36,9 +35,8 @@ void loop() { //print out the value of the pushbutton Serial.println(sensorVal); - // Keep in mind the pullup means the pushbutton's - // logic is inverted. It goes HIGH when it's open, - // and LOW when it's pressed. Turn on pin 13 when the + // Keep in mind the pull-up means the pushbutton's logic is inverted. It goes + // HIGH when it's open, and LOW when it's pressed. Turn on pin 13 when the // button's pressed, and off when it's not: if (sensorVal == HIGH) { digitalWrite(13, LOW); @@ -46,6 +44,3 @@ void loop() { digitalWrite(13, HIGH); } } - - - diff --git a/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino b/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino index 3e2f3b36508..a5ba8dab278 100644 --- a/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino +++ b/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino @@ -1,29 +1,28 @@ /* State change detection (edge detection) - Often, you don't need to know the state of a digital input all the time, - but you just need to know when the input changes from one state to another. - For example, you want to know when a button goes from OFF to ON. This is called - state change detection, or edge detection. + Often, you don't need to know the state of a digital input all the time, but + you just need to know when the input changes from one state to another. + For example, you want to know when a button goes from OFF to ON. This is called + state change detection, or edge detection. - This example shows how to detect when a button or button changes from off to on - and on to off. + This example shows how to detect when a button or button changes from off to on + and on to off. - The circuit: - * pushbutton attached to pin 2 from +5V - * 10K resistor attached to pin 2 from ground - * LED attached from pin 13 to ground (or use the built-in LED on - most Arduino boards) + The circuit: + - pushbutton attached to pin 2 from +5V + - 10 kilohm resistor attached to pin 2 from ground + - LED attached from pin 13 to ground (or use the built-in LED on most + Arduino boards) - created 27 Sep 2005 - modified 30 Aug 2011 - by Tom Igoe + created 27 Sep 2005 + modified 30 Aug 2011 + by Tom Igoe -This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/ButtonStateChange - - */ + http://www.arduino.cc/en/Tutorial/ButtonStateChange +*/ // this constant won't change: const int buttonPin = 2; // the pin that the pushbutton is attached to @@ -52,29 +51,25 @@ void loop() { if (buttonState != lastButtonState) { // if the state has changed, increment the counter if (buttonState == HIGH) { - // if the current state is HIGH then the button - // wend from off to on: + // if the current state is HIGH then the button went from off to on: buttonPushCounter++; Serial.println("on"); - Serial.print("number of button pushes: "); + Serial.print("number of button pushes: "); Serial.println(buttonPushCounter); } else { - // if the current state is LOW then the button - // wend from on to off: + // if the current state is LOW then the button went from on to off: Serial.println("off"); } // Delay a little bit to avoid bouncing delay(50); } - // save the current state as the last state, - //for next time through the loop + // save the current state as the last state, for next time through the loop lastButtonState = buttonState; - // turns on the LED every four button pushes by - // checking the modulo of the button push counter. - // the modulo function gives you the remainder of - // the division of two numbers: + // turns on the LED every four button pushes by checking the modulo of the + // button push counter. the modulo function gives you the remainder of the + // division of two numbers: if (buttonPushCounter % 4 == 0) { digitalWrite(ledPin, HIGH); } else { @@ -82,12 +77,3 @@ void loop() { } } - - - - - - - - - diff --git a/build/shared/examples/02.Digital/toneKeyboard/toneKeyboard.ino b/build/shared/examples/02.Digital/toneKeyboard/toneKeyboard.ino index 1a9c9685ca9..7a958c90aa9 100644 --- a/build/shared/examples/02.Digital/toneKeyboard/toneKeyboard.ino +++ b/build/shared/examples/02.Digital/toneKeyboard/toneKeyboard.ino @@ -1,22 +1,21 @@ /* - keyboard + Keyboard - Plays a pitch that changes based on a changing analog input + Plays a pitch that changes based on a changing analog input - circuit: - * 3 force-sensing resistors from +5V to analog in 0 through 5 - * 3 10K resistors from analog in 0 through 5 to ground - * 8-ohm speaker on digital pin 8 + circuit: + - three force-sensing resistors from +5V to analog in 0 through 5 + - three 10 kilohm resistors from analog in 0 through 5 to ground + - 8 ohm speaker on digital pin 8 - created 21 Jan 2010 - modified 9 Apr 2012 - by Tom Igoe + created 21 Jan 2010 + modified 9 Apr 2012 + by Tom Igoe -This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/Tone3 - - */ + http://www.arduino.cc/en/Tutorial/Tone3 +*/ #include "pitches.h" diff --git a/build/shared/examples/02.Digital/toneMelody/toneMelody.ino b/build/shared/examples/02.Digital/toneMelody/toneMelody.ino index 9aa81589c52..8cc1b53d071 100644 --- a/build/shared/examples/02.Digital/toneMelody/toneMelody.ino +++ b/build/shared/examples/02.Digital/toneMelody/toneMelody.ino @@ -1,20 +1,20 @@ /* Melody - Plays a melody + Plays a melody - circuit: - * 8-ohm speaker on digital pin 8 + circuit: + - 8 ohm speaker on digital pin 8 - created 21 Jan 2010 - modified 30 Aug 2011 - by Tom Igoe + created 21 Jan 2010 + modified 30 Aug 2011 + by Tom Igoe -This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/Tone + http://www.arduino.cc/en/Tutorial/Tone +*/ - */ #include "pitches.h" // notes in the melody: @@ -31,8 +31,7 @@ void setup() { // iterate over the notes of the melody: for (int thisNote = 0; thisNote < 8; thisNote++) { - // to calculate the note duration, take one second - // divided by the note type. + // to calculate the note duration, take one second divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration = 1000 / noteDurations[thisNote]; tone(8, melody[thisNote], noteDuration); diff --git a/build/shared/examples/02.Digital/toneMultiple/toneMultiple.ino b/build/shared/examples/02.Digital/toneMultiple/toneMultiple.ino index a95ad1c88e1..24cf7d687d4 100644 --- a/build/shared/examples/02.Digital/toneMultiple/toneMultiple.ino +++ b/build/shared/examples/02.Digital/toneMultiple/toneMultiple.ino @@ -1,20 +1,19 @@ /* Multiple tone player - Plays multiple tones on multiple pins in sequence + Plays multiple tones on multiple pins in sequence - circuit: - * 3 8-ohm speaker on digital pins 6, 7, and 8 + circuit: + - three 8 ohm speakers on digital pins 6, 7, and 8 - created 8 March 2010 - by Tom Igoe - based on a snippet from Greg Borenstein + created 8 Mar 2010 + by Tom Igoe + based on a snippet from Greg Borenstein -This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/Tone4 - - */ + http://www.arduino.cc/en/Tutorial/Tone4 +*/ void setup() { diff --git a/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino b/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino index 28c780d89a8..c8d85679cee 100644 --- a/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino +++ b/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino @@ -1,23 +1,21 @@ /* Pitch follower - Plays a pitch that changes based on a changing analog input + Plays a pitch that changes based on a changing analog input - circuit: - * 8-ohm speaker on digital pin 9 - * photoresistor on analog 0 to 5V - * 4.7K resistor on analog 0 to ground + circuit: + - 8 ohm speaker on digital pin 9 + - photoresistor on analog 0 to 5V + - 4.7 kilohm resistor on analog 0 to ground - created 21 Jan 2010 - modified 31 May 2012 - by Tom Igoe, with suggestion from Michael Flynn + created 21 Jan 2010 + modified 31 May 2012 + by Tom Igoe, with suggestion from Michael Flynn -This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/Tone2 - - */ + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/Tone2 +*/ void setup() { // initialize serial communications (for debugging only): @@ -31,17 +29,11 @@ void loop() { Serial.println(sensorReading); // map the analog input range (in this case, 400 - 1000 from the photoresistor) // to the output pitch range (120 - 1500Hz) - // change the minimum and maximum input numbers below - // depending on the range your sensor's giving: + // change the minimum and maximum input numbers below depending on the range + // your sensor's giving: int thisPitch = map(sensorReading, 400, 1000, 120, 1500); // play the pitch: tone(9, thisPitch, 10); delay(1); // delay in between reads for stability } - - - - - - diff --git a/build/shared/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino b/build/shared/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino index 60c52ee9e51..6675a8c88c1 100644 --- a/build/shared/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino +++ b/build/shared/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino @@ -1,26 +1,26 @@ /* Analog input, analog output, serial output - Reads an analog input pin, maps the result to a range from 0 to 255 - and uses the result to set the pulsewidth modulation (PWM) of an output pin. - Also prints the results to the serial monitor. + Reads an analog input pin, maps the result to a range from 0 to 255 and uses + the result to set the pulse width modulation (PWM) of an output pin. + Also prints the results to the Serial Monitor. - The circuit: - * potentiometer connected to analog pin 0. - Center pin of the potentiometer goes to the analog pin. - side pins of the potentiometer go to +5V and ground - * LED connected from digital pin 9 to ground + The circuit: + - potentiometer connected to analog pin 0. + Center pin of the potentiometer goes to the analog pin. + side pins of the potentiometer go to +5V and ground + - LED connected from digital pin 9 to ground - created 29 Dec. 2008 - modified 9 Apr 2012 - by Tom Igoe + created 29 Dec. 2008 + modified 9 Apr 2012 + by Tom Igoe - This example code is in the public domain. + This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/AnalogInOutSerial +*/ -// These constants won't change. They're used to give names -// to the pins used: +// 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 @@ -40,14 +40,13 @@ void loop() { // change the analog out value: analogWrite(analogOutPin, outputValue); - // print the results to the serial monitor: + // print the results to the Serial Monitor: Serial.print("sensor = "); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); - // wait 2 milliseconds before the next loop - // for the analog-to-digital converter to settle - // after the last reading: + // wait 2 milliseconds before the next loop for the analog-to-digital + // converter to settle after the last reading: delay(2); } diff --git a/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino b/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino index 0e5b212a64a..13e7b522026 100644 --- a/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino +++ b/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino @@ -1,31 +1,31 @@ /* Analog Input - Demonstrates analog input by reading an analog sensor on analog pin 0 and - turning on and off a light emitting diode(LED) connected to digital pin 13. - The amount of time the LED will be on and off depends on - the value obtained by analogRead(). - The circuit: - * Potentiometer attached to analog input 0 - * center pin of the potentiometer to the analog pin - * one side pin (either one) to ground - * the other side pin to +5V - * LED anode (long leg) attached to digital output 13 - * LED cathode (short leg) attached to ground + Demonstrates analog input by reading an analog sensor on analog pin 0 and + turning on and off a light emitting diode(LED) connected to digital pin 13. + The amount of time the LED will be on and off depends on the value obtained + by analogRead(). - * Note: because most Arduinos have a built-in LED attached - to pin 13 on the board, the LED is optional. + The circuit: + - potentiometer + center pin of the potentiometer to the analog input 0 + one side pin (either one) to ground + the other side pin to +5V + - LED + anode (long leg) attached to digital output 13 + cathode (short leg) attached to ground + - Note: because most Arduinos have a built-in LED attached to pin 13 on the + board, the LED is optional. - Created by David Cuartielles - modified 30 Aug 2011 - By Tom Igoe + created by David Cuartielles + modified 30 Aug 2011 + By Tom Igoe - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/AnalogInput - - */ + http://www.arduino.cc/en/Tutorial/AnalogInput +*/ int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED @@ -47,4 +47,4 @@ void loop() { digitalWrite(ledPin, LOW); // stop the program for for milliseconds: delay(sensorValue); -} \ No newline at end of file +} diff --git a/build/shared/examples/03.Analog/AnalogWriteMega/AnalogWriteMega.ino b/build/shared/examples/03.Analog/AnalogWriteMega/AnalogWriteMega.ino index 08e9e0455bc..37a62a1fac4 100644 --- a/build/shared/examples/03.Analog/AnalogWriteMega/AnalogWriteMega.ino +++ b/build/shared/examples/03.Analog/AnalogWriteMega/AnalogWriteMega.ino @@ -2,19 +2,20 @@ Mega analogWrite() test This sketch fades LEDs up and down one at a time on digital pins 2 through 13. - This sketch was written for the Arduino Mega, and will not work on previous boards. + This sketch was written for the Arduino Mega, and will not work on other boards. The circuit: - * LEDs attached from pins 2 through 13 to ground. + - LEDs attached from pins 2 through 13 to ground. created 8 Feb 2009 by Tom Igoe This example code is in the public domain. - */ -// These constants won't change. They're used to give names -// to the pins used: + http://www.arduino.cc/en/Tutorial/AnalogWriteMega +*/ + +// These constants won't change. They're used to give names to the pins used: const int lowestPin = 2; const int highestPin = 13; @@ -34,7 +35,7 @@ void loop() { analogWrite(thisPin, brightness); delay(2); } - // fade the LED on thisPin from brithstest to off: + // fade the LED on thisPin from brightest to off: for (int brightness = 255; brightness >= 0; brightness--) { analogWrite(thisPin, brightness); delay(2); diff --git a/build/shared/examples/03.Analog/Calibration/Calibration.ino b/build/shared/examples/03.Analog/Calibration/Calibration.ino index 7c83174e2af..5c0fc6dfa40 100644 --- a/build/shared/examples/03.Analog/Calibration/Calibration.ino +++ b/build/shared/examples/03.Analog/Calibration/Calibration.ino @@ -1,30 +1,28 @@ /* Calibration - Demonstrates one technique for calibrating sensor input. The - sensor readings during the first five seconds of the sketch - execution define the minimum and maximum of expected values - attached to the sensor pin. + Demonstrates one technique for calibrating sensor input. The sensor readings + during the first five seconds of the sketch execution define the minimum and + maximum of expected values attached to the sensor pin. - The sensor minimum and maximum initial values may seem backwards. - Initially, you set the minimum high and listen for anything - lower, saving it as the new minimum. Likewise, you set the - maximum low and listen for anything higher as the new maximum. + The sensor minimum and maximum initial values may seem backwards. Initially, + you set the minimum high and listen for anything lower, saving it as the new + minimum. Likewise, you set the maximum low and listen for anything higher as + the new maximum. - The circuit: - * Analog sensor (potentiometer will do) attached to analog input 0 - * LED attached from digital pin 9 to ground + The circuit: + - analog sensor (potentiometer will do) attached to analog input 0 + - LED attached from digital pin 9 to ground - created 29 Oct 2008 - By David A Mellis - modified 30 Aug 2011 - By Tom Igoe + created 29 Oct 2008 + by David A Mellis + modified 30 Aug 2011 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/Calibration + This example code is in the public domain. - This example code is in the public domain. - - */ + http://www.arduino.cc/en/Tutorial/Calibration +*/ // These constants won't change: const int sensorPin = A0; // pin that the sensor is attached to diff --git a/build/shared/examples/03.Analog/Fading/Fading.ino b/build/shared/examples/03.Analog/Fading/Fading.ino index f02069e0c2f..1612b8b9999 100644 --- a/build/shared/examples/03.Analog/Fading/Fading.ino +++ b/build/shared/examples/03.Analog/Fading/Fading.ino @@ -1,22 +1,20 @@ /* - Fading + Fading - This example shows how to fade an LED using the analogWrite() function. + This example shows how to fade an LED using the analogWrite() function. - The circuit: - * LED attached from digital pin 9 to ground. + The circuit: + - LED attached from digital pin 9 to ground. - Created 1 Nov 2008 - By David A. Mellis - modified 30 Aug 2011 - By Tom Igoe + created 1 Nov 2008 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/Fading - - This example code is in the public domain. - - */ + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/Fading +*/ int ledPin = 9; // LED connected to digital pin 9 @@ -41,5 +39,3 @@ void loop() { delay(30); } } - - diff --git a/build/shared/examples/03.Analog/Smoothing/Smoothing.ino b/build/shared/examples/03.Analog/Smoothing/Smoothing.ino index 9a79c9caafa..5df0d055446 100644 --- a/build/shared/examples/03.Analog/Smoothing/Smoothing.ino +++ b/build/shared/examples/03.Analog/Smoothing/Smoothing.ino @@ -1,30 +1,27 @@ /* - Smoothing - Reads repeatedly from an analog input, calculating a running average - and printing it to the computer. Keeps ten readings in an array and - continually averages them. + Reads repeatedly from an analog input, calculating a running average and + printing it to the computer. Keeps ten readings in an array and continually + averages them. The circuit: - * Analog sensor (potentiometer will do) attached to analog input 0 + - analog sensor (potentiometer will do) attached to analog input 0 - Created 22 April 2007 - By David A. Mellis + created 22 Apr 2007 + by David A. Mellis modified 9 Apr 2012 by Tom Igoe - http://www.arduino.cc/en/Tutorial/Smoothing This example code is in the public domain. - + http://www.arduino.cc/en/Tutorial/Smoothing */ - -// Define the number of samples to keep track of. The higher the number, -// the more the readings will be smoothed, but the slower the output will -// respond to the input. Using a constant rather than a normal variable lets -// use this value to determine the size of the readings array. +// Define the number of samples to keep track of. The higher the number, the +// more the readings will be smoothed, but the slower the output will respond to +// the input. Using a constant rather than a normal variable lets us use this +// value to determine the size of the readings array. const int numReadings = 10; int readings[numReadings]; // the readings from the analog input @@ -65,5 +62,3 @@ void loop() { Serial.println(average); delay(1); // delay in between reads for stability } - - diff --git a/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino b/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino index 7e41645ed60..7cf55d03ebe 100644 --- a/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino +++ b/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino @@ -1,24 +1,24 @@ /* ASCII table - Prints out byte values in all possible formats: - * as raw binary values - * as ASCII-encoded decimal, hex, octal, and binary values + Prints out byte values in all possible formats: + - as raw binary values + - as ASCII-encoded decimal, hex, octal, and binary values - For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII + For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII - The circuit: No external hardware needed. + The circuit: No external hardware needed. - created 2006 - by Nicholas Zambetti - modified 9 Apr 2012 - by Tom Igoe + created 2006 + by Nicholas Zambetti + modified 9 Apr 2012 + by Tom Igoe - This example code is in the public domain. + This example code is in the public domain. - + http://www.arduino.cc/en/Tutorial/ASCIITable +*/ - */ void setup() { //Initialize serial and wait for port to open: Serial.begin(9600); @@ -33,22 +33,22 @@ void setup() { // first visible ASCIIcharacter '!' is number 33: int thisByte = 33; // you can also write ASCII characters in single quotes. -// for example. '!' is the same as 33, so you could also use this: -//int thisByte = '!'; +// for example, '!' is the same as 33, so you could also use this: +// int thisByte = '!'; void loop() { - // prints value unaltered, i.e. the raw binary version of the - // byte. The serial monitor interprets all bytes as - // ASCII, so 33, the first number, will show up as '!' + // prints value unaltered, i.e. the raw binary version of the byte. + // The Serial Monitor interprets all bytes as ASCII, so 33, the first number, + // will show up as '!' Serial.write(thisByte); Serial.print(", dec: "); // prints value as string as an ASCII-encoded decimal (base 10). - // Decimal is the default format for Serial.print() and Serial.println(), + // Decimal is the default format for Serial.print() and Serial.println(), // so no modifier is needed: Serial.print(thisByte); // But you can declare the modifier for decimal if you want to. - //this also works if you uncomment it: + // this also works if you uncomment it: // Serial.print(thisByte, DEC); @@ -62,8 +62,7 @@ void loop() { Serial.print(thisByte, OCT); Serial.print(", bin: "); - // prints value as string in binary (base 2) - // also prints ending line break: + // prints value as string in binary (base 2) also prints ending line break: Serial.println(thisByte, BIN); // if printed last visible character '~' or 126, stop: diff --git a/build/shared/examples/04.Communication/Dimmer/Dimmer.ino b/build/shared/examples/04.Communication/Dimmer/Dimmer.ino index ef0e084de75..1388e0f109d 100644 --- a/build/shared/examples/04.Communication/Dimmer/Dimmer.ino +++ b/build/shared/examples/04.Communication/Dimmer/Dimmer.ino @@ -1,25 +1,24 @@ /* Dimmer - Demonstrates the sending data from the computer to the Arduino board, - in this case to control the brightness of an LED. The data is sent - in individual bytes, each of which ranges from 0 to 255. Arduino - reads these bytes and uses them to set the brightness of the LED. + Demonstrates sending data from the computer to the Arduino board, in this case + to control the brightness of an LED. The data is sent in individual bytes, + each of which ranges from 0 to 255. Arduino reads these bytes and uses them to + set the brightness of the LED. - The circuit: - LED attached from digital pin 9 to ground. - Serial connection to Processing, Max/MSP, or another serial application + The circuit: + - LED attached from digital pin 9 to ground. + - Serial connection to Processing, Max/MSP, or another serial application - created 2006 - by David A. Mellis - modified 30 Aug 2011 - by Tom Igoe and Scott Fitzgerald + created 2006 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe and Scott Fitzgerald - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/Dimmer - - */ + http://www.arduino.cc/en/Tutorial/Dimmer +*/ const int ledPin = 9; // the pin that the LED is attached to @@ -43,44 +42,46 @@ void loop() { } /* Processing code for this example - // Dimmer - sends bytes over a serial port - // by David A. Mellis - //This example code is in the public domain. - - import processing.serial.*; - Serial port; - - void setup() { - size(256, 150); - - println("Available serial ports:"); - // if using Processing 2.1 or later, use Serial.printArray() - println(Serial.list()); - - // Uses the first port in this list (number 0). Change this to - // select the port corresponding to your Arduino board. The last - // parameter (e.g. 9600) is the speed of the communication. It - // has to correspond to the value passed to Serial.begin() in your - // Arduino sketch. - port = new Serial(this, Serial.list()[0], 9600); - - // If you know the name of the port used by the Arduino board, you - // can specify it directly like this. - //port = new Serial(this, "COM1", 9600); - } - - void draw() { - // draw a gradient from black to white - for (int i = 0; i < 256; i++) { - stroke(i); - line(i, 0, i, 150); - } - - // write the current X-position of the mouse to the serial port as - // a single byte - port.write(mouseX); - } - */ + + // Dimmer - sends bytes over a serial port + + // by David A. Mellis + // This example code is in the public domain. + + import processing.serial.*; + Serial port; + + void setup() { + size(256, 150); + + println("Available serial ports:"); + // if using Processing 2.1 or later, use Serial.printArray() + println(Serial.list()); + + // Uses the first port in this list (number 0). Change this to select the port + // corresponding to your Arduino board. The last parameter (e.g. 9600) is the + // speed of the communication. It has to correspond to the value passed to + // Serial.begin() in your Arduino sketch. + port = new Serial(this, Serial.list()[0], 9600); + + // If you know the name of the port used by the Arduino board, you can specify + // it directly like this. + //port = new Serial(this, "COM1", 9600); + } + + void draw() { + // draw a gradient from black to white + for (int i = 0; i < 256; i++) { + stroke(i); + line(i, 0, i, 150); + } + + // write the current X-position of the mouse to the serial port as + // a single byte + port.write(mouseX); + } + +*/ /* Max/MSP v5 patch for this example @@ -109,4 +110,5 @@ D6YmX6fMznaF7kdczmJXwm.XSOOrdoHhNA7GMiZYLZZR.+4lconMaJP6JOZ8 ftCs1YWHZI3o.sIXezX5ihMSuXzZtk3ai1mXRSczoCS32hAydeyXNEu5SHyS xqZqbd3ZLdera1iPqYxOm++v7SUSz -----------end_max5_patcher----------- - */ + +*/ diff --git a/build/shared/examples/04.Communication/Graph/Graph.ino b/build/shared/examples/04.Communication/Graph/Graph.ino index db812e03449..20ad590b375 100644 --- a/build/shared/examples/04.Communication/Graph/Graph.ino +++ b/build/shared/examples/04.Communication/Graph/Graph.ino @@ -1,30 +1,29 @@ /* Graph - A simple example of communication from the Arduino board to the computer: - the value of analog input 0 is sent out the serial port. We call this "serial" - communication because the connection appears to both the Arduino and the - computer as a serial port, even though it may actually use - a USB cable. Bytes are sent one after another (serially) from the Arduino - to the computer. + A simple example of communication from the Arduino board to the computer: The + value of analog input 0 is sent out the serial port. We call this "serial" + communication because the connection appears to both the Arduino and the + computer as a serial port, even though it may actually use a USB cable. Bytes + are sent one after another (serially) from the Arduino to the computer. - You can use the Arduino serial monitor to view the sent data, or it can - be read by Processing, PD, Max/MSP, or any other program capable of reading - data from a serial port. The Processing code below graphs the data received - so you can see the value of the analog input changing over time. + You can use the Arduino Serial Monitor to view the sent data, or it can be + read by Processing, PD, Max/MSP, or any other program capable of reading data + from a serial port. The Processing code below graphs the data received so you + can see the value of the analog input changing over time. - The circuit: - Any analog input sensor is attached to analog in pin 0. + The circuit: + - any analog input sensor attached to analog in pin 0 - created 2006 - by David A. Mellis - modified 9 Apr 2012 - by Tom Igoe and Scott Fitzgerald + created 2006 + by David A. Mellis + modified 9 Apr 2012 + by Tom Igoe and Scott Fitzgerald - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/Graph - */ + http://www.arduino.cc/en/Tutorial/Graph +*/ void setup() { // initialize the serial communication: @@ -34,83 +33,83 @@ void setup() { void loop() { // send the value of analog input 0: Serial.println(analogRead(A0)); - // wait a bit for the analog-to-digital converter - // to stabilize after the last reading: + // wait a bit for the analog-to-digital converter to stabilize after the last + // reading: delay(2); } /* Processing code for this example - // Graphing sketch - + // Graphing sketch -// This program takes ASCII-encoded strings -// from the serial port at 9600 baud and graphs them. It expects values in the -// range 0 to 1023, followed by a newline, or newline and carriage return + // This program takes ASCII-encoded strings from the serial port at 9600 baud + // and graphs them. It expects values in the range 0 to 1023, followed by a + // newline, or newline and carriage return -// Created 20 Apr 2005 -// Updated 24 Nov 2015 -// by Tom Igoe -// This example code is in the public domain. + // created 20 Apr 2005 + // updated 24 Nov 2015 + // by Tom Igoe + // This example code is in the public domain. -import processing.serial.*; + import processing.serial.*; -Serial myPort; // The serial port -int xPos = 1; // horizontal position of the graph -float inByte = 0; + Serial myPort; // The serial port + int xPos = 1; // horizontal position of the graph + float inByte = 0; -void setup () { - // set the window size: - size(400, 300); + void setup () { + // set the window size: + size(400, 300); - // List all the available serial ports - // if using Processing 2.1 or later, use Serial.printArray() - println(Serial.list()); + // List all the available serial ports + // if using Processing 2.1 or later, use Serial.printArray() + println(Serial.list()); - // I know that the first port in the serial list on my mac - // is always my Arduino, so I open Serial.list()[0]. - // Open whatever port is the one you're using. - myPort = new Serial(this, Serial.list()[0], 9600); + // I know that the first port in the serial list on my Mac is always my + // Arduino, so I open Serial.list()[0]. + // Open whatever port is the one you're using. + myPort = new Serial(this, Serial.list()[0], 9600); - // don't generate a serialEvent() unless you get a newline character: - myPort.bufferUntil('\n'); + // don't generate a serialEvent() unless you get a newline character: + myPort.bufferUntil('\n'); - // set inital background: - background(0); -} -void draw () { - // draw the line: - stroke(127, 34, 255); - line(xPos, height, xPos, height - inByte); - - // at the edge of the screen, go back to the beginning: - if (xPos >= width) { - xPos = 0; + // set initial background: background(0); - } else { - // increment the horizontal position: - xPos++; } -} - -void serialEvent (Serial myPort) { - // get the ASCII string: - String inString = myPort.readStringUntil('\n'); + void draw () { + // draw the line: + stroke(127, 34, 255); + line(xPos, height, xPos, height - inByte); + + // at the edge of the screen, go back to the beginning: + if (xPos >= width) { + xPos = 0; + background(0); + } else { + // increment the horizontal position: + xPos++; + } + } - if (inString != null) { - // trim off any whitespace: - inString = trim(inString); - // convert to an int and map to the screen height: - inByte = float(inString); - println(inByte); - inByte = map(inByte, 0, 1023, 0, height); + void serialEvent (Serial myPort) { + // get the ASCII string: + String inString = myPort.readStringUntil('\n'); + + if (inString != null) { + // trim off any whitespace: + inString = trim(inString); + // convert to an int and map to the screen height: + inByte = float(inString); + println(inByte); + inByte = map(inByte, 0, 1023, 0, height); + } } -} */ /* Max/MSP v5 patch for this example + ----------begin_max5_patcher---------- 1591.3oc0YszbaaCD9r7uBL5RalQUAO3CvdyS5zVenWZxs5NcfHgjPCIfJIT RTxj+6AOHkoTDooroUs0AQPR73a+1cwtK3WtZxzEpOwqlB9YveAlL4KWMYh6 @@ -150,4 +149,4 @@ RnMj5vGl1Fs16drnk7Tf1XOLgv1n0d2iEsCxR.eQsNOZ4FGF7whofgfI3kES HJ5hhnng3h9HPj4lud02.1bxGw. -----------end_max5_patcher----------- - */ +*/ diff --git a/build/shared/examples/04.Communication/Midi/Midi.ino b/build/shared/examples/04.Communication/Midi/Midi.ino index e4de8ccb78e..5ef34062cac 100644 --- a/build/shared/examples/04.Communication/Midi/Midi.ino +++ b/build/shared/examples/04.Communication/Midi/Midi.ino @@ -1,29 +1,27 @@ /* - MIDI note player + MIDI note player - This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data. - If this circuit is connected to a MIDI synth, it will play - the notes F#-0 (0x1E) to F#-5 (0x5A) in sequence. + This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data. + If this circuit is connected to a MIDI synth, it will play the notes + F#-0 (0x1E) to F#-5 (0x5A) in sequence. + The circuit: + - digital in 1 connected to MIDI jack pin 5 + - MIDI jack pin 2 connected to ground + - MIDI jack pin 4 connected to +5V through 220 ohm resistor + - Attach a MIDI cable to the jack, then to a MIDI synth, and play music. - The circuit: - * digital in 1 connected to MIDI jack pin 5 - * MIDI jack pin 2 connected to ground - * MIDI jack pin 4 connected to +5V through 220-ohm resistor - Attach a MIDI cable to the jack, then to a MIDI synth, and play music. + created 13 Jun 2006 + modified 13 Aug 2012 + by Tom Igoe - created 13 Jun 2006 - modified 13 Aug 2012 - by Tom Igoe + This example code is in the public domain. - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/Midi - - */ + http://www.arduino.cc/en/Tutorial/Midi +*/ void setup() { - // Set MIDI baud rate: + // Set MIDI baud rate: Serial.begin(31250); } @@ -39,11 +37,10 @@ void loop() { } } -// plays a MIDI note. Doesn't check to see that -// cmd is greater than 127, or that data values are less than 127: +// plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that +// data values are less than 127: void noteOn(int cmd, int pitch, int velocity) { Serial.write(cmd); Serial.write(pitch); Serial.write(velocity); } - diff --git a/build/shared/examples/04.Communication/MultiSerial/MultiSerial.ino b/build/shared/examples/04.Communication/MultiSerial/MultiSerial.ino index ea9fa2eb212..d356f51b807 100644 --- a/build/shared/examples/04.Communication/MultiSerial/MultiSerial.ino +++ b/build/shared/examples/04.Communication/MultiSerial/MultiSerial.ino @@ -1,24 +1,23 @@ /* - Multple Serial test + Multiple Serial test - Receives from the main serial port, sends to the others. - Receives from serial port 1, sends to the main serial (Serial 0). + Receives from the main serial port, sends to the others. + Receives from serial port 1, sends to the main serial (Serial 0). - This example works only with boards with more than one serial like Arduino Mega, Due, Zero etc + This example works only with boards with more than one serial like Arduino Mega, Due, Zero etc. - The circuit: - * Any serial device attached to Serial port 1 - * Serial monitor open on Serial port 0: + The circuit: + - any serial device attached to Serial port 1 + - Serial Monitor open on Serial port 0 - created 30 Dec. 2008 - modified 20 May 2012 - by Tom Igoe & Jed Roach - modified 27 Nov 2015 - by Arturo Guadalupi + created 30 Dec 2008 + modified 20 May 2012 + by Tom Igoe & Jed Roach + modified 27 Nov 2015 + by Arturo Guadalupi - This example code is in the public domain. - - */ + This example code is in the public domain. +*/ void setup() { diff --git a/build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino b/build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino index 25556af5688..4831fd2282c 100644 --- a/build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino +++ b/build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino @@ -1,27 +1,25 @@ /* Physical Pixel - An example of using the Arduino board to receive data from the - computer. In this case, the Arduino boards turns on an LED when - it receives the character 'H', and turns off the LED when it - receives the character 'L'. + An example of using the Arduino board to receive data from the computer. In + this case, the Arduino boards turns on an LED when it receives the character + 'H', and turns off the LED when it receives the character 'L'. - The data can be sent from the Arduino serial monitor, or another - program like Processing (see code below), Flash (via a serial-net - proxy), PD, or Max/MSP. + The data can be sent from the Arduino Serial Monitor, or another program like + Processing (see code below), Flash (via a serial-net proxy), PD, or Max/MSP. - The circuit: - * LED connected from digital pin 13 to ground + The circuit: + - LED connected from digital pin 13 to ground - created 2006 - by David A. Mellis - modified 30 Aug 2011 - by Tom Igoe and Scott Fitzgerald + created 2006 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe and Scott Fitzgerald - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/PhysicalPixel - */ + http://www.arduino.cc/en/Tutorial/PhysicalPixel +*/ const int ledPin = 13; // the pin that the LED is attached to int incomingByte; // a variable to read incoming serial data into @@ -51,80 +49,73 @@ void loop() { /* Processing code for this example - // mouseover serial + // Mouse over serial - // Demonstrates how to send data to the Arduino I/O board, in order to - // turn ON a light if the mouse is over a square and turn it off - // if the mouse is not. + // Demonstrates how to send data to the Arduino I/O board, in order to turn ON + // a light if the mouse is over a square and turn it off if the mouse is not. - // created 2003-4 - // based on examples by Casey Reas and Hernando Barragan - // modified 30 Aug 2011 - // by Tom Igoe - // This example code is in the public domain. + // created 2003-4 + // based on examples by Casey Reas and Hernando Barragan + // modified 30 Aug 2011 + // by Tom Igoe + // This example code is in the public domain. + import processing.serial.*; + float boxX; + float boxY; + int boxSize = 20; + boolean mouseOverBox = false; - import processing.serial.*; + Serial port; - float boxX; - float boxY; - int boxSize = 20; - boolean mouseOverBox = false; + void setup() { + size(200, 200); + boxX = width / 2.0; + boxY = height / 2.0; + rectMode(RADIUS); - Serial port; + // List all the available serial ports in the output pane. + // You will need to choose the port that the Arduino board is connected to + // from this list. The first port in the list is port #0 and the third port + // in the list is port #2. + // if using Processing 2.1 or later, use Serial.printArray() + println(Serial.list()); - void setup() { - size(200, 200); - boxX = width/2.0; - boxY = height/2.0; - rectMode(RADIUS); - - // List all the available serial ports in the output pane. - // You will need to choose the port that the Arduino board is - // connected to from this list. The first port in the list is - // port #0 and the third port in the list is port #2. - // if using Processing 2.1 or later, use Serial.printArray() - println(Serial.list()); - - // Open the port that the Arduino board is connected to (in this case #0) - // Make sure to open the port at the same speed Arduino is using (9600bps) - port = new Serial(this, Serial.list()[0], 9600); - - } - - void draw() - { - background(0); - - // Test if the cursor is over the box - if (mouseX > boxX-boxSize && mouseX < boxX+boxSize && - mouseY > boxY-boxSize && mouseY < boxY+boxSize) { - mouseOverBox = true; - // draw a line around the box and change its color: - stroke(255); - fill(153); - // send an 'H' to indicate mouse is over square: - port.write('H'); - } - else { - // return the box to it's inactive state: - stroke(153); - fill(153); - // send an 'L' to turn the LED off: - port.write('L'); - mouseOverBox = false; - } + // Open the port that the Arduino board is connected to (in this case #0) + // Make sure to open the port at the same speed Arduino is using (9600bps) + port = new Serial(this, Serial.list()[0], 9600); + } - // Draw the box - rect(boxX, boxY, boxSize, boxSize); - } + void draw() { + background(0); + + // Test if the cursor is over the box + if (mouseX > boxX - boxSize && mouseX < boxX + boxSize && + mouseY > boxY - boxSize && mouseY < boxY + boxSize) { + mouseOverBox = true; + // draw a line around the box and change its color: + stroke(255); + fill(153); + // send an 'H' to indicate mouse is over square: + port.write('H'); + } + else { + // return the box to its inactive state: + stroke(153); + fill(153); + // send an 'L' to turn the LED off: + port.write('L'); + mouseOverBox = false; + } + // Draw the box + rect(boxX, boxY, boxSize, boxSize); + } - */ +*/ -/* -Max/MSP version 5 patch to run with this example: +/* Max/MSP version 5 patch to run with this example: ----------begin_max5_patcher---------- 1672.3oc2ZszaaiCD9ryuBBebQVCQRYao8xhf1cQCPVfBzh8RRQ.sDsM2HSZ @@ -167,5 +158,4 @@ hN97JSnSfLUXGUoj6ujWXd6Pk1SAC+Pkogm.tZ.1lX1qL.pe6PE11DPeMMZ2 .P0K+3peBt3NskC -----------end_max5_patcher----------- - - */ +*/ diff --git a/build/shared/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino b/build/shared/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino index 074c9c78976..ab26c282a6d 100644 --- a/build/shared/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino +++ b/build/shared/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino @@ -1,24 +1,23 @@ /* Reading a serial ASCII-encoded string. - This sketch demonstrates the Serial parseInt() function. - It looks for an ASCII string of comma-separated values. - It parses them into ints, and uses those to fade an RGB LED. + This sketch demonstrates the Serial parseInt() function. + It looks for an ASCII string of comma-separated values. + It parses them into ints, and uses those to fade an RGB LED. - Circuit: Common-Cathode RGB LED wired like so: - * Red anode: digital pin 3 - * Green anode: digital pin 5 - * Blue anode: digital pin 6 - * Cathode : GND + Circuit: Common-Cathode RGB LED wired like so: + - red anode: digital pin 3 + - green anode: digital pin 5 + - blue anode: digital pin 6 + - cathode: GND - created 13 Apr 2012 - by Tom Igoe - - modified 14 Mar 2016 - by Arturo Guadalupi + created 13 Apr 2012 + by Tom Igoe + modified 14 Mar 2016 + by Arturo Guadalupi - This example code is in the public domain. - */ + This example code is in the public domain. +*/ // pins for the LEDs: const int redPin = 3; @@ -46,8 +45,7 @@ void loop() { // do it again: int blue = Serial.parseInt(); - // look for the newline. That's the end of your - // sentence: + // look for the newline. That's the end of your sentence: if (Serial.read() == '\n') { // constrain the values to 0 - 255 and invert // if you're using a common-cathode LED, just use "constrain(color, 0, 255);" @@ -67,11 +65,3 @@ void loop() { } } } - - - - - - - - diff --git a/build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino b/build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino index 23d74c3ec18..880e899e5ae 100644 --- a/build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino +++ b/build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino @@ -1,28 +1,25 @@ /* Serial Call and Response - Language: Wiring/Arduino + Language: Wiring/Arduino - This program sends an ASCII A (byte of value 65) on startup - and repeats that until it gets some data in. - Then it waits for a byte in the serial port, and - sends three sensor values whenever it gets a byte in. + This program sends an ASCII A (byte of value 65) on startup and repeats that + until it gets some data in. Then it waits for a byte in the serial port, and + sends three sensor values whenever it gets a byte in. - Thanks to Greg Shakar and Scott Fitzgerald for the improvements + The circuit: + - potentiometers attached to analog inputs 0 and 1 + - pushbutton attached to digital I/O 2 - The circuit: - * potentiometers attached to analog inputs 0 and 1 - * pushbutton attached to digital I/O 2 + created 26 Sep 2005 + by Tom Igoe + modified 24 Apr 2012 + by Tom Igoe and Scott Fitzgerald + Thanks to Greg Shakar and Scott Fitzgerald for the improvements - Created 26 Sept. 2005 - by Tom Igoe - modified 24 April 2012 - by Tom Igoe and Scott Fitzgerald + This example code is in the public domain. - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/SerialCallResponse - - */ + http://www.arduino.cc/en/Tutorial/SerialCallResponse +*/ int firstSensor = 0; // first analog sensor int secondSensor = 0; // second analog sensor @@ -51,7 +48,7 @@ void loop() { delay(10); // read second analog input, divide by 4 to make the range 0-255: secondSensor = analogRead(1) / 4; - // read switch, map it to 0 or 255L + // read switch, map it to 0 or 255L thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: Serial.write(firstSensor); @@ -67,87 +64,85 @@ void establishContact() { } } -/* -Processing sketch to run with this example: +/* Processing sketch to run with this example: -// This example code is in the public domain. + // This example code is in the public domain. -import processing.serial.*; + import processing.serial.*; -int bgcolor; // Background color -int fgcolor; // Fill color -Serial myPort; // The serial port -int[] serialInArray = new int[3]; // Where we'll put what we receive -int serialCount = 0; // A count of how many bytes we receive -int xpos, ypos; // Starting position of the ball -boolean firstContact = false; // Whether we've heard from the microcontroller + int bgcolor; // Background color + int fgcolor; // Fill color + Serial myPort; // The serial port + int[] serialInArray = new int[3]; // Where we'll put what we receive + int serialCount = 0; // A count of how many bytes we receive + int xpos, ypos; // Starting position of the ball + boolean firstContact = false; // Whether we've heard from the microcontroller -void setup() { - size(256, 256); // Stage size - noStroke(); // No border on the next thing drawn - - // Set the starting position of the ball (middle of the stage) - xpos = width/2; - ypos = height/2; - - // Print a list of the serial ports for debugging purposes - // if using Processing 2.1 or later, use Serial.printArray() - println(Serial.list()); - - // I know that the first port in the serial list on my mac - // is always my FTDI adaptor, so I open Serial.list()[0]. - // On Windows machines, this generally opens COM1. - // Open whatever port is the one you're using. - String portName = Serial.list()[0]; - myPort = new Serial(this, portName, 9600); -} + void setup() { + size(256, 256); // Stage size + noStroke(); // No border on the next thing drawn -void draw() { - background(bgcolor); - fill(fgcolor); - // Draw the shape - ellipse(xpos, ypos, 20, 20); -} + // Set the starting position of the ball (middle of the stage) + xpos = width / 2; + ypos = height / 2; -void serialEvent(Serial myPort) { - // read a byte from the serial port: - int inByte = myPort.read(); - // if this is the first byte received, and it's an A, - // clear the serial buffer and note that you've - // had first contact from the microcontroller. - // Otherwise, add the incoming byte to the array: - if (firstContact == false) { - if (inByte == 'A') { - myPort.clear(); // clear the serial port buffer - firstContact = true; // you've had first contact from the microcontroller - myPort.write('A'); // ask for more - } + // Print a list of the serial ports for debugging purposes + // if using Processing 2.1 or later, use Serial.printArray() + println(Serial.list()); + + // I know that the first port in the serial list on my Mac is always my FTDI + // adaptor, so I open Serial.list()[0]. + // On Windows machines, this generally opens COM1. + // Open whatever port is the one you're using. + String portName = Serial.list()[0]; + myPort = new Serial(this, portName, 9600); } - else { - // Add the latest byte from the serial port to array: - serialInArray[serialCount] = inByte; - serialCount++; - - // If we have 3 bytes: - if (serialCount > 2 ) { - xpos = serialInArray[0]; - ypos = serialInArray[1]; - fgcolor = serialInArray[2]; - - // print the values (for debugging purposes only): - println(xpos + "\t" + ypos + "\t" + fgcolor); - - // Send a capital A to request new sensor readings: - myPort.write('A'); - // Reset serialCount: - serialCount = 0; + + void draw() { + background(bgcolor); + fill(fgcolor); + // Draw the shape + ellipse(xpos, ypos, 20, 20); + } + + void serialEvent(Serial myPort) { + // read a byte from the serial port: + int inByte = myPort.read(); + // if this is the first byte received, and it's an A, clear the serial + // buffer and note that you've had first contact from the microcontroller. + // Otherwise, add the incoming byte to the array: + if (firstContact == false) { + if (inByte == 'A') { + myPort.clear(); // clear the serial port buffer + firstContact = true; // you've had first contact from the microcontroller + myPort.write('A'); // ask for more + } + } + else { + // Add the latest byte from the serial port to array: + serialInArray[serialCount] = inByte; + serialCount++; + + // If we have 3 bytes: + if (serialCount > 2 ) { + xpos = serialInArray[0]; + ypos = serialInArray[1]; + fgcolor = serialInArray[2]; + + // print the values (for debugging purposes only): + println(xpos + "\t" + ypos + "\t" + fgcolor); + + // Send a capital A to request new sensor readings: + myPort.write('A'); + // Reset serialCount: + serialCount = 0; + } } } -} + */ -/* -Max/MSP version 5 patch to run with this example: +/* Max/MSP version 5 patch to run with this example: ----------begin_max5_patcher---------- 3908.3oc6ckziiaiE9b0+J3XjCIXpp.WzZNMURv.jCInQ5fYNjNngrDssRKK @@ -239,6 +234,4 @@ UB9onw9mlFQ10fhpZBaDatcMTTEGcJpwzqg92qqiVtM6Cu0IRQ0ndEdfCAqV l0qYAUmPrctbxO4XCuPMa1asYzKDks1D52ZCne6Mednz9qW8+.vfqkDA -----------end_max5_patcher----------- - - */ diff --git a/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino b/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino index 551c4921b61..78edcb74024 100644 --- a/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino +++ b/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino @@ -1,32 +1,26 @@ /* Serial Call and Response in ASCII - Language: Wiring/Arduino + Language: Wiring/Arduino - This program sends an ASCII A (byte of value 65) on startup - and repeats that until it gets some data in. - Then it waits for a byte in the serial port, and - sends three ASCII-encoded, comma-separated sensor values, - truncated by a linefeed and carriage return, - whenever it gets a byte in. - - Thanks to Greg Shakar and Scott Fitzgerald for the improvements + This program sends an ASCII A (byte of value 65) on startup and repeats that + until it gets some data in. Then it waits for a byte in the serial port, and + sends three ASCII-encoded, comma-separated sensor values, truncated by a + linefeed and carriage return, whenever it gets a byte in. The circuit: - * potentiometers attached to analog inputs 0 and 1 - * pushbutton attached to digital I/O 2 - - - - Created 26 Sept. 2005 - by Tom Igoe - modified 24 Apr 2012 - by Tom Igoe and Scott Fitzgerald + - potentiometers attached to analog inputs 0 and 1 + - pushbutton attached to digital I/O 2 - This example code is in the public domain. + created 26 Sep 2005 + by Tom Igoe + modified 24 Apr 2012 + by Tom Igoe and Scott Fitzgerald + Thanks to Greg Shakar and Scott Fitzgerald for the improvements - http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII + This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII +*/ int firstSensor = 0; // first analog sensor int secondSensor = 0; // second analog sensor @@ -54,7 +48,7 @@ void loop() { firstSensor = analogRead(A0); // read second analog input: secondSensor = analogRead(A1); - // read switch, map it to 0 or 255L + // read switch, map it to 0 or 255 thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: Serial.print(firstSensor); @@ -72,58 +66,55 @@ void establishContact() { } } +/* Processing code to run with this example: -/* -Processing code to run with this example: + // This example code is in the public domain. -// This example code is in the public domain. + import processing.serial.*; // import the Processing serial library + Serial myPort; // The serial port -import processing.serial.*; // import the Processing serial library -Serial myPort; // The serial port + float bgcolor; // Background color + float fgcolor; // Fill color + float xpos, ypos; // Starting position of the ball -float bgcolor; // Background color -float fgcolor; // Fill color -float xpos, ypos; // Starting position of the ball + void setup() { + size(640, 480); -void setup() { - size(640,480); + // List all the available serial ports + // if using Processing 2.1 or later, use Serial.printArray() + println(Serial.list()); - // List all the available serial ports - // if using Processing 2.1 or later, use Serial.printArray() - println(Serial.list()); + // I know that the first port in the serial list on my Mac is always my + // Arduino board, so I open Serial.list()[0]. + // Change the 0 to the appropriate number of the serial port that your + // microcontroller is attached to. + myPort = new Serial(this, Serial.list()[0], 9600); - // I know that the first port in the serial list on my mac - // is always my Arduino module, so I open Serial.list()[0]. - // Change the 0 to the appropriate number of the serial port - // that your microcontroller is attached to. - myPort = new Serial(this, Serial.list()[0], 9600); + // read bytes into a buffer until you get a linefeed (ASCII 10): + myPort.bufferUntil('\n'); - // read bytes into a buffer until you get a linefeed (ASCII 10): - myPort.bufferUntil('\n'); - - // draw with smooth edges: - smooth(); -} + // draw with smooth edges: + smooth(); + } -void draw() { - background(bgcolor); - fill(fgcolor); - // Draw the shape - ellipse(xpos, ypos, 20, 20); -} + void draw() { + background(bgcolor); + fill(fgcolor); + // Draw the shape + ellipse(xpos, ypos, 20, 20); + } -// serialEvent method is run automatically by the Processing applet -// whenever the buffer reaches the byte value set in the bufferUntil() -// method in the setup(): + // serialEvent method is run automatically by the Processing applet whenever + // the buffer reaches the byte value set in the bufferUntil() + // method in the setup(): -void serialEvent(Serial myPort) { - // read the serial buffer: - String myString = myPort.readStringUntil('\n'); - // if you got any bytes other than the linefeed: + void serialEvent(Serial myPort) { + // read the serial buffer: + String myString = myPort.readStringUntil('\n'); + // if you got any bytes other than the linefeed: myString = trim(myString); - // split the string at the commas - // and convert the sections into integers: + // split the string at the commas and convert the sections into integers: int sensors[] = int(split(myString, ',')); // print out the values you got: @@ -133,8 +124,8 @@ void serialEvent(Serial myPort) { // add a linefeed after all the sensor values are printed: println(); if (sensors.length > 1) { - xpos = map(sensors[0], 0,1023,0,width); - ypos = map(sensors[1], 0,1023,0,height); + xpos = map(sensors[0], 0, 1023, 0, width); + ypos = map(sensors[1], 0, 1023, 0, height); fgcolor = sensors[2]; } // send a byte to ask for more data: @@ -143,9 +134,8 @@ void serialEvent(Serial myPort) { */ -/* +/* Max/MSP version 5 patch to run with this example: -Max/MSP version 5 patch to run with this example: ----------begin_max5_patcher---------- 3640.3oc6cs0jZajE94Y9UzKkeHoVloTeSHkm1II0VkeHIthSs6C1obIjZ.E KjHRhY7jT4+9d5KBj.jTCAXfoV6x.sj5VmyWet127ed6MCFm8EQw.z2f9.5l diff --git a/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino b/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino index 94a3cc39feb..43f9eaf4e55 100644 --- a/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino +++ b/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino @@ -1,26 +1,24 @@ /* Serial Event example - When new serial data arrives, this sketch adds it to a String. - When a newline is received, the loop prints the string and - clears it. + When new serial data arrives, this sketch adds it to a String. + When a newline is received, the loop prints the string and clears it. - A good test for this is to try it with a GPS receiver - that sends out NMEA 0183 sentences. + A good test for this is to try it with a GPS receiver that sends out + NMEA 0183 sentences. - NOTE: The serialEvent() feature is not available on the - Leonardo, Micro, or other ATmega32U4 based boards. - - Created 9 May 2011 - by Tom Igoe + NOTE: The serialEvent() feature is not available on the Leonardo, Micro, or + other ATmega32U4 based boards. - This example code is in the public domain. + created 9 May 2011 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/SerialEvent + This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/SerialEvent +*/ -String inputString = ""; // a string to hold incoming data +String inputString = ""; // a String to hold incoming data boolean stringComplete = false; // whether the string is complete void setup() { @@ -41,23 +39,20 @@ void loop() { } /* - SerialEvent occurs whenever a new data comes in the - hardware serial RX. This routine is run between each - time loop() runs, so using delay inside loop can delay - response. Multiple bytes of data may be available. - */ + SerialEvent occurs whenever a new data comes in the hardware serial RX. This + routine is run between each time loop() runs, so using delay inside loop can + delay response. Multiple bytes of data may be available. +*/ void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; - // if the incoming character is a newline, set a flag - // so the main loop can do something about it: + // if the incoming character is a newline, set a flag so the main loop can + // do something about it: if (inChar == '\n') { stringComplete = true; } } } - - diff --git a/build/shared/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino b/build/shared/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino index 5650abbaf4d..81037ebdcd6 100644 --- a/build/shared/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino +++ b/build/shared/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino @@ -1,26 +1,25 @@ /* SerialPassthrough sketch - Some boards, like the Arduino 101, the MKR1000, Zero, or the Micro, - have one hardware serial port attached to Digital pins 0-1, and a - separate USB serial port attached to the IDE Serial Monitor. - This means that the "serial passthrough" which is possible with - the Arduino UNO (commonly used to interact with devices/shields that - require configuration via serial AT commands) will not work by default. + Some boards, like the Arduino 101, the MKR1000, Zero, or the Micro, have one + hardware serial port attached to Digital pins 0-1, and a separate USB serial + port attached to the IDE Serial Monitor. This means that the "serial + passthrough" which is possible with the Arduino UNO (commonly used to interact + with devices/shields that require configuration via serial AT commands) will + not work by default. - This sketch allows you to emulate the serial passthrough behaviour. - Any text you type in the IDE Serial monitor will be written - out to the serial port on Digital pins 0 and 1, and vice-versa. + This sketch allows you to emulate the serial passthrough behaviour. Any text + you type in the IDE Serial monitor will be written out to the serial port on + Digital pins 0 and 1, and vice-versa. On the 101, MKR1000, Zero, and Micro, "Serial" refers to the USB Serial port - attached to the Serial Monitor, and "Serial1" refers to the hardware - serial port attached to pins 0 and 1. This sketch will emulate Serial passthrough - using those two Serial ports on the boards mentioned above, - but you can change these names to connect any two serial ports on a board - that has multiple ports. + attached to the Serial Monitor, and "Serial1" refers to the hardware serial + port attached to pins 0 and 1. This sketch will emulate Serial passthrough + using those two Serial ports on the boards mentioned above, but you can change + these names to connect any two serial ports on a board that has multiple ports. - Created 23 May 2016 - by Erik Nyquist + created 23 May 2016 + by Erik Nyquist */ void setup() { diff --git a/build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino b/build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino index b9a6df1da0e..4124074ec76 100644 --- a/build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino +++ b/build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino @@ -1,20 +1,20 @@ /* - This example reads three analog sensors (potentiometers are easiest) - and sends their values serially. The Processing and Max/MSP programs at the bottom - take those three values and use them to change the background color of the screen. + This example reads three analog sensors (potentiometers are easiest) and sends + their values serially. The Processing and Max/MSP programs at the bottom take + those three values and use them to change the background color of the screen. - The circuit: - * potentiometers attached to analog inputs 0, 1, and 2 + The circuit: + - potentiometers attached to analog inputs 0, 1, and 2 - http://www.arduino.cc/en/Tutorial/VirtualColorMixer - - created 2 Dec 2006 - by David A. Mellis - modified 30 Aug 2011 - by Tom Igoe and Scott Fitzgerald + created 2 Dec 2006 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe and Scott Fitzgerald This example code is in the public domain. - */ + + http://www.arduino.cc/en/Tutorial/VirtualColorMixer +*/ const int redPin = A0; // sensor to control red color const int greenPin = A1; // sensor to control green color @@ -34,59 +34,58 @@ void loop() { /* Processing code for this example -// This example code is in the public domain. + // This example code is in the public domain. -import processing.serial.*; + import processing.serial.*; -float redValue = 0; // red value -float greenValue = 0; // green value -float blueValue = 0; // blue value + float redValue = 0; // red value + float greenValue = 0; // green value + float blueValue = 0; // blue value -Serial myPort; + Serial myPort; -void setup() { - size(200, 200); - - // List all the available serial ports - // if using Processing 2.1 or later, use Serial.printArray() - println(Serial.list()); - - // I know that the first port in the serial list on my mac - // is always my Arduino, so I open Serial.list()[0]. - // Open whatever port is the one you're using. - myPort = new Serial(this, Serial.list()[0], 9600); - // don't generate a serialEvent() unless you get a newline character: - myPort.bufferUntil('\n'); -} + void setup() { + size(200, 200); -void draw() { - // set the background color with the color values: - background(redValue, greenValue, blueValue); -} + // List all the available serial ports + // if using Processing 2.1 or later, use Serial.printArray() + println(Serial.list()); -void serialEvent(Serial myPort) { - // get the ASCII string: - String inString = myPort.readStringUntil('\n'); - - if (inString != null) { - // trim off any whitespace: - inString = trim(inString); - // split the string on the commas and convert the - // resulting substrings into an integer array: - float[] colors = float(split(inString, ",")); - // if the array has at least three elements, you know - // you got the whole thing. Put the numbers in the - // color variables: - if (colors.length >=3) { - // map them to the range 0-255: - redValue = map(colors[0], 0, 1023, 0, 255); - greenValue = map(colors[1], 0, 1023, 0, 255); - blueValue = map(colors[2], 0, 1023, 0, 255); + // I know that the first port in the serial list on my Mac is always my + // Arduino, so I open Serial.list()[0]. + // Open whatever port is the one you're using. + myPort = new Serial(this, Serial.list()[0], 9600); + // don't generate a serialEvent() unless you get a newline character: + myPort.bufferUntil('\n'); + } + + void draw() { + // set the background color with the color values: + background(redValue, greenValue, blueValue); + } + + void serialEvent(Serial myPort) { + // get the ASCII string: + String inString = myPort.readStringUntil('\n'); + + if (inString != null) { + // trim off any whitespace: + inString = trim(inString); + // split the string on the commas and convert the resulting substrings + // into an integer array: + float[] colors = float(split(inString, ",")); + // if the array has at least three elements, you know you got the whole + // thing. Put the numbers in the color variables: + if (colors.length >= 3) { + // map them to the range 0-255: + redValue = map(colors[0], 0, 1023, 0, 255); + greenValue = map(colors[1], 0, 1023, 0, 255); + blueValue = map(colors[2], 0, 1023, 0, 255); + } } } -} - */ +*/ /* Max/MSP patch for this example @@ -127,5 +126,4 @@ ASi6Zyw8.RQi65J8ZsNx3ho93OhGWENtWpowepae4YhCFeLErOLENtXJrOSc iadi39rf4hwc8xdhHz3gn3dBI7iDRlFe8huAfIZhq -----------end_max5_patcher----------- - - */ +*/ diff --git a/build/shared/examples/05.Control/Arrays/Arrays.ino b/build/shared/examples/05.Control/Arrays/Arrays.ino index 37b7a5e983f..549ac3463f4 100644 --- a/build/shared/examples/05.Control/Arrays/Arrays.ino +++ b/build/shared/examples/05.Control/Arrays/Arrays.ino @@ -1,25 +1,24 @@ /* Arrays - Demonstrates the use of an array to hold pin numbers - in order to iterate over the pins in a sequence. - Lights multiple LEDs in sequence, then in reverse. + Demonstrates the use of an array to hold pin numbers in order to iterate over + the pins in a sequence. Lights multiple LEDs in sequence, then in reverse. - Unlike the For Loop tutorial, where the pins have to be - contiguous, here the pins can be in any random order. + Unlike the For Loop tutorial, where the pins have to be contiguous, here the + pins can be in any random order. - The circuit: - * LEDs from pins 2 through 7 to ground + The circuit: + - LEDs from pins 2 through 7 to ground - created 2006 - by David A. Mellis - modified 30 Aug 2011 - by Tom Igoe + created 2006 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe -This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/Array - */ + http://www.arduino.cc/en/Tutorial/Array +*/ int timer = 100; // The higher the number, the slower the timing. int ledPins[] = { diff --git a/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.ino b/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.ino index 0aa922b24c6..54ad38a2695 100644 --- a/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.ino +++ b/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.ino @@ -1,21 +1,21 @@ /* For Loop Iteration - Demonstrates the use of a for() loop. - Lights multiple LEDs in sequence, then in reverse. + Demonstrates the use of a for() loop. + Lights multiple LEDs in sequence, then in reverse. - The circuit: - * LEDs from pins 2 through 7 to ground + The circuit: + - LEDs from pins 2 through 7 to ground - created 2006 - by David A. Mellis - modified 30 Aug 2011 - by Tom Igoe + created 2006 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe -This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/ForLoop - */ + http://www.arduino.cc/en/Tutorial/ForLoop +*/ int timer = 100; // The higher the number, the slower the timing. diff --git a/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.txt b/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.txt index 8c6a729f930..fcc65b42c15 100644 --- a/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.txt +++ b/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.txt @@ -1 +1 @@ -Controlling multiple LEDs with a for loop and. \ No newline at end of file +Controlling multiple LEDs with a for loop. \ No newline at end of file diff --git a/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino b/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino index d9a4acf3eff..4dd40901d1e 100644 --- a/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino +++ b/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino @@ -1,29 +1,28 @@ /* Conditionals - If statement - This example demonstrates the use of if() statements. - It reads the state of a potentiometer (an analog input) and turns on an LED - only if the potentiometer goes above a certain threshold level. It prints the analog value - regardless of the level. + This example demonstrates the use of if() statements. + It reads the state of a potentiometer (an analog input) and turns on an LED + only if the potentiometer goes above a certain threshold level. It prints the + analog value regardless of the level. - The circuit: - * potentiometer connected to analog pin 0. - Center pin of the potentiometer goes to the analog pin. - side pins of the potentiometer go to +5V and ground - * LED connected from digital pin 13 to ground + The circuit: + - potentiometer + Center pin of the potentiometer goes to analog pin 0. + Side pins of the potentiometer go to +5V and ground. + - LED connected from digital pin 13 to ground - * Note: On most Arduino boards, there is already an LED on the board - connected to pin 13, so you don't need any extra components for this example. + - Note: On most Arduino boards, there is already an LED on the board connected + to pin 13, so you don't need any extra components for this example. - created 17 Jan 2009 - modified 9 Apr 2012 - by Tom Igoe + created 17 Jan 2009 + modified 9 Apr 2012 + by Tom Igoe -This example code is in the public domain. + This example code is in the public domain. -http://www.arduino.cc/en/Tutorial/IfStatement - - */ + http://www.arduino.cc/en/Tutorial/IfStatement +*/ // These constants won't change: const int analogPin = A0; // pin that the sensor is attached to @@ -52,4 +51,3 @@ void loop() { Serial.println(analogValue); delay(1); // delay in between reads for stability } - diff --git a/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino b/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino index f17038c7ba7..4f1383f5edc 100644 --- a/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino +++ b/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino @@ -1,32 +1,31 @@ /* Conditionals - while statement - This example demonstrates the use of while() statements. + This example demonstrates the use of while() statements. - While the pushbutton is pressed, the sketch runs the calibration routine. - The sensor readings during the while loop define the minimum and maximum - of expected values from the photo resistor. + While the pushbutton is pressed, the sketch runs the calibration routine. + The sensor readings during the while loop define the minimum and maximum of + expected values from the photoresistor. - This is a variation on the calibrate example. + This is a variation on the calibrate example. - The circuit: - * photo resistor connected from +5V to analog in pin 0 - * 10K resistor connected from ground to analog in pin 0 - * LED connected from digital pin 9 to ground through 220 ohm resistor - * pushbutton attached from pin 2 to +5V - * 10K resistor attached from pin 2 to ground + The circuit: + - photoresistor connected from +5V to analog in pin 0 + - 10 kilohm resistor connected from ground to analog in pin 0 + - LED connected from digital pin 9 to ground through 220 ohm resistor + - pushbutton attached from pin 2 to +5V + - 10 kilohm resistor attached from pin 2 to ground - created 17 Jan 2009 - modified 30 Aug 2011 - by Tom Igoe - modified 20 Jan 2017 - by Arturo Guadalupi + created 17 Jan 2009 + modified 30 Aug 2011 + by Tom Igoe + modified 20 Jan 2017 + by Arturo Guadalupi - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/WhileLoop - - */ + http://www.arduino.cc/en/Tutorial/WhileLoop +*/ // These constants won't change: @@ -86,5 +85,3 @@ void calibrate() { sensorMin = sensorValue; } } - - diff --git a/build/shared/examples/05.Control/switchCase/switchCase.ino b/build/shared/examples/05.Control/switchCase/switchCase.ino index 1572f73e441..c313f6b9885 100644 --- a/build/shared/examples/05.Control/switchCase/switchCase.ino +++ b/build/shared/examples/05.Control/switchCase/switchCase.ino @@ -1,29 +1,28 @@ /* Switch statement - Demonstrates the use of a switch statement. The switch - statement allows you to choose from among a set of discrete values - of a variable. It's like a series of if statements. + Demonstrates the use of a switch statement. The switch statement allows you + to choose from among a set of discrete values of a variable. It's like a + series of if statements. - To see this sketch in action, but the board and sensor in a well-lit - room, open the serial monitor, and and move your hand gradually - down over the sensor. + To see this sketch in action, put the board and sensor in a well-lit room, + open the Serial Monitor, and move your hand gradually down over the sensor. - The circuit: - * photoresistor from analog in 0 to +5V - * 10K resistor from analog in 0 to ground + The circuit: + - photoresistor from analog in 0 to +5V + - 10K resistor from analog in 0 to ground - created 1 Jul 2009 - modified 9 Apr 2012 - by Tom Igoe + created 1 Jul 2009 + modified 9 Apr 2012 + by Tom Igoe - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/SwitchCase - */ + http://www.arduino.cc/en/Tutorial/SwitchCase +*/ -// these constants won't change. They are the -// lowest and highest readings you get from your sensor: +// 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 @@ -38,8 +37,7 @@ void loop() { // map the sensor range to a range of four options: int range = map(sensorReading, sensorMin, sensorMax, 0, 3); - // do something different depending on the - // range value: + // do something different depending on the range value: switch (range) { case 0: // your hand is on the sensor Serial.println("dark"); @@ -56,8 +54,3 @@ void loop() { } delay(1); // delay in between reads for stability } - - - - - diff --git a/build/shared/examples/05.Control/switchCase2/switchCase2.ino b/build/shared/examples/05.Control/switchCase2/switchCase2.ino index 19215d9ea63..c30843f730a 100644 --- a/build/shared/examples/05.Control/switchCase2/switchCase2.ino +++ b/build/shared/examples/05.Control/switchCase2/switchCase2.ino @@ -1,24 +1,24 @@ /* - Switch statement with serial input + Switch statement with serial input - Demonstrates the use of a switch statement. The switch - statement allows you to choose from among a set of discrete values - of a variable. It's like a series of if statements. + Demonstrates the use of a switch statement. The switch statement allows you + to choose from among a set of discrete values of a variable. It's like a + series of if statements. - To see this sketch in action, open the Serial monitor and send any character. - The characters a, b, c, d, and e, will turn on LEDs. Any other character will turn - the LEDs off. + To see this sketch in action, open the Serial monitor and send any character. + The characters a, b, c, d, and e, will turn on LEDs. Any other character will + turn the LEDs off. - The circuit: - * 5 LEDs attached to digital pins 2 through 6 through 220-ohm resistors + The circuit: + - five LEDs attached to digital pins 2 through 6 through 220 ohm resistors - created 1 Jul 2009 - by Tom Igoe + created 1 Jul 2009 + by Tom Igoe -This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/SwitchCase2 - */ + http://www.arduino.cc/en/Tutorial/SwitchCase2 +*/ void setup() { // initialize serial communication: @@ -34,10 +34,10 @@ void loop() { if (Serial.available() > 0) { int inByte = Serial.read(); // do something different depending on the character received. - // The switch statement expects single number values for each case; - // in this exmaple, though, you're using single quotes to tell - // the controller to get the ASCII value for the character. For - // example 'a' = 97, 'b' = 98, and so forth: + // The switch statement expects single number values for each case; in this + // example, though, you're using single quotes to tell the controller to get + // the ASCII value for the character. For example 'a' = 97, 'b' = 98, + // and so forth: switch (inByte) { case 'a': @@ -63,4 +63,3 @@ void loop() { } } } - diff --git a/build/shared/examples/06.Sensors/ADXL3xx/ADXL3xx.ino b/build/shared/examples/06.Sensors/ADXL3xx/ADXL3xx.ino index 2515d60a09c..1cf4be447af 100644 --- a/build/shared/examples/06.Sensors/ADXL3xx/ADXL3xx.ino +++ b/build/shared/examples/06.Sensors/ADXL3xx/ADXL3xx.ino @@ -1,29 +1,27 @@ - /* - ADXL3xx - - Reads an Analog Devices ADXL3xx accelerometer and communicates the - acceleration to the computer. The pins used are designed to be easily - compatible with the breakout boards from Sparkfun, available from: - http://www.sparkfun.com/commerce/categories.php?c=80 + ADXL3xx - http://www.arduino.cc/en/Tutorial/ADXL3xx + Reads an Analog Devices ADXL3xx accelerometer and communicates the + acceleration to the computer. The pins used are designed to be easily + compatible with the breakout boards from SparkFun, available from: + http://www.sparkfun.com/commerce/categories.php?c=80 - The circuit: - analog 0: accelerometer self test - analog 1: z-axis - analog 2: y-axis - analog 3: x-axis - analog 4: ground - analog 5: vcc + The circuit: + - analog 0: accelerometer self test + - analog 1: z-axis + - analog 2: y-axis + - analog 3: x-axis + - analog 4: ground + - analog 5: vcc - created 2 Jul 2008 - by David A. Mellis - modified 30 Aug 2011 - by Tom Igoe + created 2 Jul 2008 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe - This example code is in the public domain. + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/ADXL3xx */ // these constants describe the pins. They won't change: @@ -37,10 +35,10 @@ void setup() { // initialize the serial communications: Serial.begin(9600); - // Provide ground and power by using the analog inputs as normal - // digital pins. This makes it possible to directly connect the - // breakout board to the Arduino. If you use the normal 5V and - // GND pins on the Arduino, you can remove these lines. + // Provide ground and power by using the analog inputs as normal digital pins. + // This makes it possible to directly connect the breakout board to the + // Arduino. If you use the normal 5V and GND pins on the Arduino, + // you can remove these lines. pinMode(groundpin, OUTPUT); pinMode(powerpin, OUTPUT); digitalWrite(groundpin, LOW); diff --git a/build/shared/examples/06.Sensors/Knock/Knock.ino b/build/shared/examples/06.Sensors/Knock/Knock.ino index 98c64ffb00c..99b50e4de47 100644 --- a/build/shared/examples/06.Sensors/Knock/Knock.ino +++ b/build/shared/examples/06.Sensors/Knock/Knock.ino @@ -1,29 +1,29 @@ -/* Knock Sensor +/* + Knock Sensor - This sketch reads a piezo element to detect a knocking sound. - It reads an analog pin and compares the result to a set threshold. - If the result is greater than the threshold, it writes - "knock" to the serial port, and toggles the LED on pin 13. + This sketch reads a piezo element to detect a knocking sound. + It reads an analog pin and compares the result to a set threshold. + If the result is greater than the threshold, it writes "knock" to the serial + port, and toggles the LED on pin 13. - The circuit: - * + connection of the piezo attached to analog in 0 - * - connection of the piezo attached to ground - * 1-megohm resistor attached from analog in 0 to ground + The circuit: + - positive connection of the piezo attached to analog in 0 + - negative connection of the piezo attached to ground + - 1 megohm resistor attached from analog in 0 to ground - http://www.arduino.cc/en/Tutorial/Knock + created 25 Mar 2007 + by David Cuartielles + modified 30 Aug 2011 + by Tom Igoe - created 25 Mar 2007 - by David Cuartielles - modified 30 Aug 2011 - by Tom Igoe + This example code is in the public domain. - This example code is in the public domain. - - */ + http://www.arduino.cc/en/Tutorial/Knock +*/ // these constants won't change: -const int ledPin = 13; // led connected to digital pin 13 +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 @@ -52,4 +52,3 @@ void loop() { } delay(100); // delay to avoid overloading the serial port buffer } - diff --git a/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.ino b/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.ino index 74c504bb831..da69df9d1d9 100644 --- a/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.ino +++ b/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.ino @@ -1,27 +1,25 @@ /* - Memsic2125 + Memsic2125 - Read the Memsic 2125 two-axis accelerometer. Converts the - pulses output by the 2125 into milli-g's (1/1000 of earth's - gravity) and prints them over the serial connection to the - computer. + Read the Memsic 2125 two-axis accelerometer. Converts the pulses output by the + 2125 into milli-g's (1/1000 of Earth's gravity) and prints them over the + serial connection to the computer. - The circuit: - * X output of accelerometer to digital pin 2 - * Y output of accelerometer to digital pin 3 - * +V of accelerometer to +5V - * GND of accelerometer to ground + The circuit: + - X output of accelerometer to digital pin 2 + - Y output of accelerometer to digital pin 3 + - +V of accelerometer to +5V + - GND of accelerometer to ground - http://www.arduino.cc/en/Tutorial/Memsic2125 + created 6 Nov 2008 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe - created 6 Nov 2008 - by David A. Mellis - modified 30 Aug 2011 - by Tom Igoe + This example code is in the public domain. - This example code is in the public domain. - - */ + http://www.arduino.cc/en/Tutorial/Memsic2125 +*/ // these constants won't change: const int xPin = 2; // X output of the accelerometer @@ -30,8 +28,7 @@ const int yPin = 3; // Y output of the accelerometer void setup() { // initialize serial communications: Serial.begin(9600); - // initialize the pins connected to the accelerometer - // as inputs: + // initialize the pins connected to the accelerometer as inputs: pinMode(xPin, INPUT); pinMode(yPin, INPUT); } @@ -48,7 +45,7 @@ void loop() { // convert the pulse width into acceleration // accelerationX and accelerationY are in milli-g's: - // earth's gravity is 1000 milli-g's, or 1g. + // Earth's gravity is 1000 milli-g's, or 1 g. accelerationX = ((pulseX / 10) - 500) * 8; accelerationY = ((pulseY / 10) - 500) * 8; diff --git a/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.txt b/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.txt index 04bd5ece63b..003eb39107b 100644 --- a/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.txt +++ b/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.txt @@ -1 +1 @@ -Two-axis acceleromoter. \ No newline at end of file +Two-axis accelerometer. \ No newline at end of file diff --git a/build/shared/examples/06.Sensors/Ping/Ping.ino b/build/shared/examples/06.Sensors/Ping/Ping.ino index ab0cb899cd8..cdde18e45b7 100644 --- a/build/shared/examples/06.Sensors/Ping/Ping.ino +++ b/build/shared/examples/06.Sensors/Ping/Ping.ino @@ -1,29 +1,27 @@ -/* Ping))) Sensor +/* + Ping))) Sensor - This sketch reads a PING))) ultrasonic rangefinder and returns the - distance to the closest object in range. To do this, it sends a pulse - to the sensor to initiate a reading, then listens for a pulse - to return. The length of the returning pulse is proportional to - the distance of the object from the sensor. + This sketch reads a PING))) ultrasonic rangefinder and returns the distance + to the closest object in range. To do this, it sends a pulse to the sensor to + initiate a reading, then listens for a pulse to return. The length of the + returning pulse is proportional to the distance of the object from the sensor. - The circuit: - * +V connection of the PING))) attached to +5V - * GND connection of the PING))) attached to ground - * SIG connection of the PING))) attached to digital pin 7 + The circuit: + - +V connection of the PING))) attached to +5V + - GND connection of the PING))) attached to ground + - SIG connection of the PING))) attached to digital pin 7 - http://www.arduino.cc/en/Tutorial/Ping + created 3 Nov 2008 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe - created 3 Nov 2008 - by David A. Mellis - modified 30 Aug 2011 - by Tom Igoe + This example code is in the public domain. - This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/Ping +*/ - */ - -// this constant won't change. It's the pin number -// of the sensor's output: +// this constant won't change. It's the pin number of the sensor's output: const int pingPin = 7; void setup() { @@ -32,8 +30,8 @@ void setup() { } void loop() { - // establish variables for duration of the ping, - // and the distance result in inches and centimeters: + // establish variables for duration of the ping, and the distance result + // in inches and centimeters: long duration, inches, cm; // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. @@ -45,9 +43,9 @@ void loop() { delayMicroseconds(5); digitalWrite(pingPin, LOW); - // The same pin is used to read the signal from the PING))): a HIGH - // pulse whose duration is the time (in microseconds) from the sending - // of the ping to the reception of its echo off of an object. + // The same pin is used to read the signal from the PING))): a HIGH pulse + // whose duration is the time (in microseconds) from the sending of the ping + // to the reception of its echo off of an object. pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); @@ -65,17 +63,17 @@ void loop() { } long microsecondsToInches(long microseconds) { - // According to Parallax's datasheet for the PING))), there are - // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per - // second). This gives the distance travelled by the ping, outbound - // and return, so we divide by 2 to get the distance of the obstacle. + // According to Parallax's datasheet for the PING))), there are 73.746 + // microseconds per inch (i.e. sound travels at 1130 feet per second). + // This gives the distance travelled by the ping, outbound and return, + // so we divide by 2 to get the distance of the obstacle. // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf return microseconds / 74 / 2; } long microsecondsToCentimeters(long microseconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. - // The ping travels out and back, so to find the distance of the - // object we take half of the distance travelled. + // The ping travels out and back, so to find the distance of the object we + // take half of the distance travelled. return microseconds / 29 / 2; } diff --git a/build/shared/examples/07.Display/RowColumnScanning/RowColumnScanning.ino b/build/shared/examples/07.Display/RowColumnScanning/RowColumnScanning.ino index a7f623a5e4e..f2cf79525f3 100644 --- a/build/shared/examples/07.Display/RowColumnScanning/RowColumnScanning.ino +++ b/build/shared/examples/07.Display/RowColumnScanning/RowColumnScanning.ino @@ -1,38 +1,37 @@ /* Row-Column Scanning an 8x8 LED matrix with X-Y input - This example controls an 8x8 LED matrix using two analog inputs + This example controls an 8x8 LED matrix using two analog inputs. - created 27 May 2009 - modified 30 Aug 2011 - by Tom Igoe + This example works for the Lumex LDM-24488NI Matrix. See + http://sigma.octopart.com/140413/datasheet/Lumex-LDM-24488NI.pdf + for the pin connections. - This example works for the Lumex LDM-24488NI Matrix. See - http://sigma.octopart.com/140413/datasheet/Lumex-LDM-24488NI.pdf - for the pin connections + For other LED cathode column matrixes, you should only need to change the pin + numbers in the row[] and column[] arrays. - For other LED cathode column matrixes, you should only need to change - the pin numbers in the row[] and column[] arrays + rows are the anodes + cols are the cathodes + --------- - rows are the anodes - cols are the cathodes - --------- + Pin numbers: + Matrix: + - digital pins 2 through 13, + - analog pins 2 through 5 used as digital 16 through 19 + Potentiometers: + - center pins are attached to analog pins 0 and 1, respectively + - side pins attached to +5V and ground, respectively - Pin numbers: - Matrix: - * Digital pins 2 through 13, - * analog pins 2 through 5 used as digital 16 through 19 - Potentiometers: - * center pins are attached to analog pins 0 and 1, respectively - * side pins attached to +5V and ground, respectively. + created 27 May 2009 + modified 30 Aug 2011 + by Tom Igoe - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/RowColumnScanning - - see also http://www.tigoe.net/pcomp/code/category/arduinowiring/514 for more - */ + http://www.arduino.cc/en/Tutorial/RowColumnScanning + see also http://www.tigoe.net/pcomp/code/category/arduinowiring for more +*/ // 2-dimensional array of row pin numbers: const int row[8] = { @@ -52,14 +51,12 @@ int x = 5; int y = 5; void setup() { - // initialize the I/O pins as outputs - // iterate over the pins: + // initialize the I/O pins as outputs iterate over the pins: for (int thisPin = 0; thisPin < 8; thisPin++) { // initialize the output pins: pinMode(col[thisPin], OUTPUT); pinMode(row[thisPin], OUTPUT); - // take the col pins (i.e. the cathodes) high to ensure that - // the LEDS are off: + // take the col pins (i.e. the cathodes) high to ensure that the LEDS are off: digitalWrite(col[thisPin], HIGH); } @@ -85,8 +82,8 @@ void readSensors() { // read the sensors for X and Y values: x = 7 - map(analogRead(A0), 0, 1023, 0, 7); y = map(analogRead(A1), 0, 1023, 0, 7); - // set the new pixel position low so that the LED will turn on - // in the next screen refresh: + // set the new pixel position low so that the LED will turn on in the next + // screen refresh: pixels[x][y] = LOW; } diff --git a/build/shared/examples/07.Display/barGraph/barGraph.ino b/build/shared/examples/07.Display/barGraph/barGraph.ino index 2de75b8a4aa..48327a98b51 100644 --- a/build/shared/examples/07.Display/barGraph/barGraph.ino +++ b/build/shared/examples/07.Display/barGraph/barGraph.ino @@ -2,24 +2,23 @@ LED bar graph Turns on a series of LEDs based on the value of an analog sensor. - This is a simple way to make a bar graph display. Though this graph - uses 10 LEDs, you can use any number by changing the LED count - and the pins in the array. + This is a simple way to make a bar graph display. Though this graph uses 10 + LEDs, you can use any number by changing the LED count and the pins in the + array. - This method can be used to control any series of digital outputs that - depends on an analog input. + This method can be used to control any series of digital outputs that depends + on an analog input. The circuit: - * LEDs from pins 2 through 11 to ground + - LEDs from pins 2 through 11 to ground - created 4 Sep 2010 - by Tom Igoe + created 4 Sep 2010 + by Tom Igoe - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/BarGraph - */ + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/BarGraph +*/ // these constants won't change: const int analogPin = A0; // the pin that the potentiometer is attached to @@ -56,6 +55,3 @@ void loop() { } } } - - - diff --git a/build/shared/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino b/build/shared/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino index 19b5be6ec97..07a89c582e3 100644 --- a/build/shared/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino +++ b/build/shared/examples/08.Strings/CharacterAnalysis/CharacterAnalysis.ino @@ -1,15 +1,17 @@ /* Character analysis operators - Examples using the character analysis operators. - Send any byte and the sketch will tell you about it. + Examples using the character analysis operators. + Send any byte and the sketch will tell you about it. - created 29 Nov 2010 - modified 2 Apr 2012 - by Tom Igoe + created 29 Nov 2010 + modified 2 Apr 2012 + by Tom Igoe - This example code is in the public domain. - */ + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/CharacterAnalysis +*/ void setup() { // Open serial communications and wait for port to open: diff --git a/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino b/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino index 7e56b975d15..5f65e502074 100644 --- a/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino +++ b/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino @@ -1,19 +1,19 @@ /* Adding Strings together - Examples of how to add strings together - You can also add several different data types to string, as shown here: + Examples of how to add Strings together + You can also add several different data types to String, as shown here: - created 27 July 2010 - modified 2 Apr 2012 - by Tom Igoe + created 27 Jul 2010 + modified 2 Apr 2012 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringAdditionOperator + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringAdditionOperator +*/ -// declare three strings: +// declare three Strings: String stringOne, stringTwo, stringThree; void setup() { @@ -27,40 +27,40 @@ void setup() { stringTwo = String("this string"); stringThree = String(); // send an intro: - Serial.println("\n\nAdding strings together (concatenation):"); + Serial.println("\n\nAdding Strings together (concatenation):"); Serial.println(); } void loop() { - // adding a constant integer to a string: + // adding a constant integer to a String: stringThree = stringOne + 123; Serial.println(stringThree); // prints "You added 123" - // adding a constant long interger to a string: + // adding a constant long integer to a String: stringThree = stringOne + 123456789; Serial.println(stringThree); // prints "You added 123456789" - // adding a constant character to a string: + // adding a constant character to a String: stringThree = stringOne + 'A'; Serial.println(stringThree); // prints "You added A" - // adding a constant string to a string: + // adding a constant string to a String: stringThree = stringOne + "abc"; Serial.println(stringThree); // prints "You added abc" stringThree = stringOne + stringTwo; Serial.println(stringThree); // prints "You added this string" - // adding a variable integer to a 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 - // adding a variable long integer to a string: + // adding a variable long integer to a String: stringOne = "millis() value: "; stringThree = stringOne + millis(); - Serial.println(stringThree); // prints "The millis: 345345" or whatever value currentTime has + Serial.println(stringThree); // prints "The millis: 345345" or whatever value millis() has // do nothing while true: while (true); diff --git a/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.txt b/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.txt index c93c9f83a5e..94d8f649170 100644 --- a/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.txt +++ b/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.txt @@ -1 +1 @@ -Add strings together in a variety of ways. \ No newline at end of file +Add Strings together in a variety of ways. \ No newline at end of file diff --git a/build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino b/build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino index 97e81741b56..abdfe76a331 100644 --- a/build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino +++ b/build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino @@ -1,16 +1,16 @@ /* Appending to Strings using the += operator and concat() - Examples of how to append different data types to strings + Examples of how to append different data types to Strings - created 27 July 2010 - modified 2 Apr 2012 - by Tom Igoe + created 27 Jul 2010 + modified 2 Apr 2012 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringAppendOperator + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringAppendOperator +*/ String stringOne, stringTwo; @@ -24,34 +24,34 @@ void setup() { stringOne = String("Sensor "); stringTwo = String("value"); // send an intro: - Serial.println("\n\nAppending to a string:"); + Serial.println("\n\nAppending to a String:"); Serial.println(); } void loop() { Serial.println(stringOne); // prints "Sensor " - // adding a string to a string: + // adding a string to a String: stringOne += stringTwo; Serial.println(stringOne); // prints "Sensor value" - // adding a constant string to a string: + // adding a constant string to a String: stringOne += " for input "; Serial.println(stringOne); // prints "Sensor value for input" - // adding a constant character to a string: + // adding a constant character to a String: stringOne += 'A'; Serial.println(stringOne); // prints "Sensor value for input A" - // adding a constant integer to a string: + // adding a constant integer to a String: stringOne += 0; Serial.println(stringOne); // prints "Sensor value for input A0" - // adding a constant string to a string: + // adding a constant string to a String: stringOne += ": "; Serial.println(stringOne); // prints "Sensor value for input" - // adding a variable integer to a string: + // 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 @@ -59,15 +59,14 @@ void loop() { stringOne = "A long integer: "; stringTwo = "The millis(): "; - // adding a constant long integer to a string: + // adding a constant long integer to a String: stringOne += 123456789; Serial.println(stringOne); // prints "A long integer: 123456789" - // using concat() to add a long variable to a string: + // 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 // do nothing while true: while (true); } - diff --git a/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino b/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino index c9c8fc87507..78a12705298 100644 --- a/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino +++ b/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino @@ -1,16 +1,16 @@ /* String Case changes - Examples of how to change the case of a string + Examples of how to change the case of a String - created 27 July 2010 - modified 2 Apr 2012 - by Tom Igoe + created 27 Jul 2010 + modified 2 Apr 2012 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringCaseChanges + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringCaseChanges +*/ void setup() { // Open serial communications and wait for port to open: @@ -20,7 +20,7 @@ void setup() { } // send an intro: - Serial.println("\n\nString case changes:"); + Serial.println("\n\nString case changes:"); Serial.println(); } diff --git a/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.txt b/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.txt index 75d11af3f98..c0c0e4a9ed0 100644 --- a/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.txt +++ b/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.txt @@ -1 +1 @@ -Change the case of a string. \ No newline at end of file +Change the case of a String. \ No newline at end of file diff --git a/build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino b/build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino index dbb1f0a08e2..f985e7929d1 100644 --- a/build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino +++ b/build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino @@ -1,16 +1,16 @@ /* String charAt() and setCharAt() - Examples of how to get and set characters of a String + Examples of how to get and set characters of a String - created 27 July 2010 - modified 2 Apr 2012 - by Tom Igoe + created 27 Jul 2010 + modified 2 Apr 2012 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringCharacters + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringCharacters +*/ void setup() { // Open serial communications and wait for port to open: @@ -19,11 +19,11 @@ void setup() { ; // wait for serial port to connect. Needed for native USB port only } - Serial.println("\n\nString charAt() and setCharAt():"); + Serial.println("\n\nString charAt() and setCharAt():"); } void loop() { - // make a string to report a sensor reading: + // make a String to report a sensor reading: String reportString = "SensorReading: 456"; Serial.println(reportString); @@ -36,11 +36,10 @@ void loop() { // add blank space: Serial.println(); - // you can alo set the character of a string. Change the : to a = character + // you can also set the character of a String. Change the : to a = character reportString.setCharAt(13, '='); Serial.println(reportString); // do nothing while true: while (true); } - diff --git a/build/shared/examples/08.Strings/StringCharacters/StringCharacters.txt b/build/shared/examples/08.Strings/StringCharacters/StringCharacters.txt index d43da1f0289..a1bcb85563f 100644 --- a/build/shared/examples/08.Strings/StringCharacters/StringCharacters.txt +++ b/build/shared/examples/08.Strings/StringCharacters/StringCharacters.txt @@ -1 +1 @@ -Get/set the value of a specific character in a string. \ No newline at end of file +Get/set the value of a specific character in a String. \ No newline at end of file diff --git a/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino b/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino index 1417a8b7aba..48540f9cd67 100644 --- a/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino +++ b/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino @@ -1,16 +1,16 @@ /* Comparing Strings - Examples of how to compare strings using the comparison operators + Examples of how to compare Strings using the comparison operators - created 27 July 2010 - modified 2 Apr 2012 - by Tom Igoe + created 27 Jul 2010 + modified 2 Apr 2012 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringComparisonOperators + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringComparisonOperators +*/ String stringOne, stringTwo; @@ -31,22 +31,22 @@ void setup() { } void loop() { - // two strings equal: + // two Strings equal: if (stringOne == "this") { Serial.println("StringOne == \"this\""); } - // two strings not equal: + // two Strings not equal: if (stringOne != stringTwo) { Serial.println(stringOne + " =! " + stringTwo); } - // two strings not equal (case sensitivity matters): + // two Strings not equal (case sensitivity matters): stringOne = "This"; stringTwo = "this"; if (stringOne != stringTwo) { Serial.println(stringOne + " =! " + stringTwo); } - // you can also use equals() to see if two strings are the same: + // you can also use equals() to see if two Strings are the same: if (stringOne.equals(stringTwo)) { Serial.println(stringOne + " equals " + stringTwo); } else { @@ -60,7 +60,7 @@ void loop() { Serial.println(stringOne + " does not equal (ignoring case) " + stringTwo); } - // a numeric string compared to the number it represents: + // a numeric String compared to the number it represents: stringOne = "1"; int numberOne = 1; if (stringOne.toInt() == numberOne) { @@ -69,14 +69,14 @@ void loop() { - // two numeric strings compared: + // two numeric Strings compared: stringOne = "2"; stringTwo = "1"; if (stringOne >= stringTwo) { Serial.println(stringOne + " >= " + stringTwo); } - // comparison operators can be used to compare strings for alphabetic sorting too: + // comparison operators can be used to compare Strings for alphabetic sorting too: stringOne = String("Brown"); if (stringOne < "Charles") { Serial.println(stringOne + " < Charles"); @@ -95,10 +95,10 @@ void loop() { Serial.println(stringOne + " >= Brow"); } - // the compareTo() operator also allows you to compare strings + // the compareTo() operator also allows you to compare Strings // it evaluates on the first character that's different. - // if the first character of the string you're comparing to - // comes first in alphanumeric order, then compareTo() is greater than 0: + // if the first character of the String you're comparing to comes first in + // alphanumeric order, then compareTo() is greater than 0: stringOne = "Cucumber"; stringTwo = "Cucuracha"; if (stringOne.compareTo(stringTwo) < 0) { @@ -109,7 +109,7 @@ void loop() { delay(10000); // because the next part is a loop: - // compareTo() is handy when you've got strings with numbers in them too: + // compareTo() is handy when you've got Strings with numbers in them too: while (true) { stringOne = "Sensor: "; diff --git a/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.txt b/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.txt index aa622c764b4..95cf1c794e8 100644 --- a/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.txt +++ b/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.txt @@ -1 +1 @@ -Compare strings alphabetically. \ No newline at end of file +Compare Strings alphabetically. \ No newline at end of file diff --git a/build/shared/examples/08.Strings/StringConstructors/StringConstructors.ino b/build/shared/examples/08.Strings/StringConstructors/StringConstructors.ino index 1fef29c4258..414dd8dca06 100644 --- a/build/shared/examples/08.Strings/StringConstructors/StringConstructors.ino +++ b/build/shared/examples/08.Strings/StringConstructors/StringConstructors.ino @@ -1,16 +1,16 @@ /* - String constructors + String constructors - Examples of how to create strings from other data types + Examples of how to create Strings from other data types - created 27 July 2010 - modified 30 Aug 2011 - by Tom Igoe + created 27 Jul 2010 + modified 30 Aug 2011 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringConstructors + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringConstructors +*/ void setup() { // Open serial communications and wait for port to open: @@ -66,11 +66,11 @@ void loop() { // prints "123456" or whatever the value of millis() is: Serial.println(stringOne); - //using a float and the right decimal places: + // using a float and the right decimal places: stringOne = String(5.698, 3); Serial.println(stringOne); - //using a float and less decimal places to use rounding: + // using a float and less decimal places to use rounding: stringOne = String(5.698, 2); Serial.println(stringOne); diff --git a/build/shared/examples/08.Strings/StringConstructors/StringConstructors.txt b/build/shared/examples/08.Strings/StringConstructors/StringConstructors.txt index 777082fb710..d58dface816 100644 --- a/build/shared/examples/08.Strings/StringConstructors/StringConstructors.txt +++ b/build/shared/examples/08.Strings/StringConstructors/StringConstructors.txt @@ -1 +1 @@ -How to initialize string objects. \ No newline at end of file +How to initialize String objects. \ No newline at end of file diff --git a/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino b/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino index 584b15795d6..bac9f81ef6b 100644 --- a/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino +++ b/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino @@ -1,16 +1,16 @@ /* String indexOf() and lastIndexOf() functions - Examples of how to evaluate, look for, and replace characters in a String + Examples of how to evaluate, look for, and replace characters in a String - created 27 July 2010 - modified 2 Apr 2012 - by Tom Igoe + created 27 Jul 2010 + modified 2 Apr 2012 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringIndexOf + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringIndexOf +*/ void setup() { // Open serial communications and wait for port to open: @@ -25,8 +25,8 @@ void setup() { } void loop() { - // indexOf() returns the position (i.e. index) of a particular character - // in a string. For example, if you were parsing HTML tags, you could use it: + // indexOf() returns the position (i.e. index) of a particular character in a + // String. For example, if you were parsing HTML tags, you could use it: String stringOne = ""; int firstClosingBracket = stringOne.indexOf('>'); Serial.println("The index of > in the string " + stringOne + " is " + firstClosingBracket); @@ -63,4 +63,3 @@ void loop() { // do nothing while true: while (true); } - diff --git a/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.txt b/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.txt index cd972295372..d7f6d8d69bc 100644 --- a/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.txt +++ b/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.txt @@ -1 +1 @@ -Look for the first/last instance of a character in a string. \ No newline at end of file +Look for the first/last instance of a character in a String. \ No newline at end of file diff --git a/build/shared/examples/08.Strings/StringLength/StringLength.ino b/build/shared/examples/08.Strings/StringLength/StringLength.ino index 35f315c7f51..0fe5203b90f 100644 --- a/build/shared/examples/08.Strings/StringLength/StringLength.ino +++ b/build/shared/examples/08.Strings/StringLength/StringLength.ino @@ -1,16 +1,16 @@ /* String length() - Examples of how to use length() in a String. - Open the Serial Monitor and start sending characters to see the results. + Examples of how to use length() in a String. + Open the Serial Monitor and start sending characters to see the results. - created 1 Aug 2010 - by Tom Igoe + created 1 Aug 2010 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringLengthTrim + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringLengthTrim +*/ String txtMsg = ""; // a string for incoming text unsigned int lastStringLength = txtMsg.length(); // previous length of the String diff --git a/build/shared/examples/08.Strings/StringLength/StringLength.txt b/build/shared/examples/08.Strings/StringLength/StringLength.txt index 862d0476e2f..7ffb9c31283 100644 --- a/build/shared/examples/08.Strings/StringLength/StringLength.txt +++ b/build/shared/examples/08.Strings/StringLength/StringLength.txt @@ -1 +1 @@ -Get and trim the length of a string. \ No newline at end of file +Examples of how to use length() in a String. \ No newline at end of file diff --git a/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino b/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino index 805ac0ed548..d107c8f09e7 100644 --- a/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino +++ b/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino @@ -1,16 +1,16 @@ /* String length() and trim() - Examples of how to use length() and trim() in a String + Examples of how to use length() and trim() in a String - created 27 July 2010 - modified 2 Apr 2012 - by Tom Igoe + created 27 Jul 2010 + modified 2 Apr 2012 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringLengthTrim + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringLengthTrim +*/ void setup() { // Open serial communications and wait for port to open: @@ -20,7 +20,7 @@ void setup() { } // send an intro: - Serial.println("\n\nString length() and trim():"); + Serial.println("\n\nString length() and trim():"); Serial.println(); } diff --git a/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.txt b/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.txt index 862d0476e2f..43dcaa984db 100644 --- a/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.txt +++ b/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.txt @@ -1 +1 @@ -Get and trim the length of a string. \ No newline at end of file +Get and trim the length of a String. \ No newline at end of file diff --git a/build/shared/examples/08.Strings/StringReplace/StringReplace.ino b/build/shared/examples/08.Strings/StringReplace/StringReplace.ino index 960aa6af7a8..17407f1ec13 100644 --- a/build/shared/examples/08.Strings/StringReplace/StringReplace.ino +++ b/build/shared/examples/08.Strings/StringReplace/StringReplace.ino @@ -1,16 +1,16 @@ /* String replace() - Examples of how to replace characters or substrings of a string + Examples of how to replace characters or substrings of a String - created 27 July 2010 - modified 2 Apr 2012 - by Tom Igoe + created 27 Jul 2010 + modified 2 Apr 2012 + by Tom Igoe - http://www.arduino.cc/en/Tutorial/StringReplace + This example code is in the public domain. - This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/StringReplace +*/ void setup() { // Open serial communications and wait for port to open: @@ -20,7 +20,7 @@ void setup() { } // send an intro: - Serial.println("\n\nString replace:\n"); + Serial.println("\n\nString replace:\n"); Serial.println(); } @@ -28,7 +28,7 @@ void loop() { String stringOne = ""; Serial.println(stringOne); // replace() changes all instances of one substring with another: - // first, make a copy of th original string: + // first, make a copy of the original string: String stringTwo = stringOne; // then perform the replacements: stringTwo.replace("<", " 0) { int inChar = Serial.read(); if (isDigit(inChar)) { - // convert the incoming byte to a char - // and add it to the string: + // convert the incoming byte to a char and add it to the string: inString += (char)inChar; } - // if you get a newline, print the string, - // then the string's value: + // if you get a newline, print the string, then the string's value: if (inChar == '\n') { Serial.print("Value:"); Serial.println(inString.toInt()); @@ -48,4 +48,3 @@ void loop() { } } } - diff --git a/build/shared/examples/09.USB/Keyboard/KeyboardLogout/KeyboardLogout.ino b/build/shared/examples/09.USB/Keyboard/KeyboardLogout/KeyboardLogout.ino index 9bd7b032d89..f6ea490c2d7 100644 --- a/build/shared/examples/09.USB/Keyboard/KeyboardLogout/KeyboardLogout.ino +++ b/build/shared/examples/09.USB/Keyboard/KeyboardLogout/KeyboardLogout.ino @@ -1,29 +1,29 @@ /* Keyboard logout - This sketch demonstrates the Keyboard library. + This sketch demonstrates the Keyboard library. - When you connect pin 2 to ground, it performs a logout. - It uses keyboard combinations to do this, as follows: + When you connect pin 2 to ground, it performs a logout. + It uses keyboard combinations to do this, as follows: - On Windows, CTRL-ALT-DEL followed by ALT-l - On Ubuntu, CTRL-ALT-DEL, and ENTER - On OSX, CMD-SHIFT-q + On Windows, CTRL-ALT-DEL followed by ALT-l + On Ubuntu, CTRL-ALT-DEL, and ENTER + On OSX, CMD-SHIFT-q - To wake: Spacebar. + To wake: Spacebar. - Circuit: - * Arduino Leonardo or Micro - * wire to connect D2 to ground. + Circuit: + - Arduino Leonardo or Micro + - wire to connect D2 to ground - created 6 Mar 2012 - modified 27 Mar 2012 - by Tom Igoe + created 6 Mar 2012 + modified 27 Mar 2012 + by Tom Igoe - This example is in the public domain + This example is in the public domain. - http://www.arduino.cc/en/Tutorial/KeyboardLogout - */ + http://www.arduino.cc/en/Tutorial/KeyboardLogout +*/ #define OSX 0 #define WINDOWS 1 @@ -35,8 +35,7 @@ int platform = OSX; void setup() { - // make pin 2 an input and turn on the - // pullup resistor so it goes high unless + // make pin 2 an input and turn on the pull-up resistor so it goes high unless // connected to ground: pinMode(2, INPUT_PULLUP); Keyboard.begin(); @@ -67,7 +66,7 @@ void loop() { Keyboard.press(KEY_DELETE); delay(100); Keyboard.releaseAll(); - //ALT-l: + // ALT-l: delay(2000); Keyboard.press(KEY_LEFT_ALT); Keyboard.press('l'); @@ -88,11 +87,3 @@ void loop() { // do nothing: while (true); } - - - - - - - - diff --git a/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino b/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino index d0022c4fadb..32c3b9f81ce 100644 --- a/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino +++ b/build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino @@ -1,24 +1,24 @@ /* - Keyboard Message test + Keyboard Message test - For the Arduino Leonardo and Micro. + For the Arduino Leonardo and Micro. - Sends a text string when a button is pressed. + Sends a text string when a button is pressed. - The circuit: - * pushbutton attached from pin 4 to +5V - * 10-kilohm resistor attached from pin 4 to ground + The circuit: + - pushbutton attached from pin 4 to +5V + - 10 kilohm resistor attached from pin 4 to ground - created 24 Oct 2011 - modified 27 Mar 2012 - by Tom Igoe - modified 11 Nov 2013 - by Scott Fitzgerald + created 24 Oct 2011 + modified 27 Mar 2012 + by Tom Igoe + modified 11 Nov 2013 + by Scott Fitzgerald - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/KeyboardMessage - */ + http://www.arduino.cc/en/Tutorial/KeyboardMessage +*/ #include "Keyboard.h" @@ -50,4 +50,3 @@ void loop() { // save the current button state for comparison next time: previousButtonState = buttonState; } - diff --git a/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino b/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino index 86a6e1158db..7ec0d6d8974 100644 --- a/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino +++ b/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino @@ -1,31 +1,29 @@ /* Arduino Programs Blink - This sketch demonstrates the Keyboard library. + This sketch demonstrates the Keyboard library. - For Leonardo and Due boards only. + For Leonardo and Due boards only. - When you connect pin 2 to ground, it creates a new - window with a key combination (CTRL-N), - then types in the Blink sketch, then auto-formats the text - using another key combination (CTRL-T), then - uploads the sketch to the currently selected Arduino using - a final key combination (CTRL-U). + When you connect pin 2 to ground, it creates a new window with a key + combination (CTRL-N), then types in the Blink sketch, then auto-formats the + text using another key combination (CTRL-T), then uploads the sketch to the + currently selected Arduino using a final key combination (CTRL-U). - Circuit: - * Arduino Leonardo, Micro, Due, LilyPad USB, or Yún - * wire to connect D2 to ground. + Circuit: + - Arduino Leonardo, Micro, Due, LilyPad USB, or Yún + - wire to connect D2 to ground - created 5 Mar 2012 - modified 29 Mar 2012 - by Tom Igoe - modified 3 May 2014 - by Scott Fitzgerald + created 5 Mar 2012 + modified 29 Mar 2012 + by Tom Igoe + modified 3 May 2014 + by Scott Fitzgerald - This example is in the public domain + This example is in the public domain. - http://www.arduino.cc/en/Tutorial/KeyboardReprogram - */ + http://www.arduino.cc/en/Tutorial/KeyboardReprogram +*/ #include "Keyboard.h" @@ -38,8 +36,7 @@ char ctrlKey = KEY_LEFT_GUI; void setup() { - // make pin 2 an input and turn on the - // pullup resistor so it goes high unless + // make pin 2 an input and turn on the pull-up resistor so it goes high unless // connected to ground: pinMode(2, INPUT_PULLUP); // initialize control over the keyboard: @@ -60,10 +57,9 @@ void loop() { // wait for new window to open: delay(1000); - // versions of the Arduino IDE after 1.5 pre-populate - // new sketches with setup() and loop() functions - // let's clear the window before typing anything new - // select all + // versions of the Arduino IDE after 1.5 pre-populate new sketches with + // setup() and loop() functions let's clear the window before typing anything new + // select all Keyboard.press(ctrlKey); Keyboard.press('a'); delay(500); @@ -105,10 +101,3 @@ void loop() { // wait for the sweet oblivion of reprogramming: while (true); } - - - - - - - diff --git a/build/shared/examples/09.USB/Keyboard/KeyboardSerial/KeyboardSerial.ino b/build/shared/examples/09.USB/Keyboard/KeyboardSerial/KeyboardSerial.ino index a3310f7cc84..72d9dddf538 100644 --- a/build/shared/examples/09.USB/Keyboard/KeyboardSerial/KeyboardSerial.ino +++ b/build/shared/examples/09.USB/Keyboard/KeyboardSerial/KeyboardSerial.ino @@ -1,23 +1,23 @@ /* - Keyboard test + Keyboard test - For the Arduino Leonardo, Micro or Due + For the Arduino Leonardo, Micro or Due - Reads a byte from the serial port, sends a keystroke back. - The sent keystroke is one higher than what's received, e.g. - if you send a, you get b, send A you get B, and so forth. + Reads a byte from the serial port, sends a keystroke back. + The sent keystroke is one higher than what's received, e.g. if you send a, + you get b, send A you get B, and so forth. - The circuit: - * none + The circuit: + - none - created 21 Oct 2011 - modified 27 Mar 2012 - by Tom Igoe + created 21 Oct 2011 + modified 27 Mar 2012 + by Tom Igoe - This example code is in the public domain. + This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/KeyboardSerial - */ + http://www.arduino.cc/en/Tutorial/KeyboardSerial +*/ #include "Keyboard.h" @@ -37,4 +37,3 @@ void loop() { Keyboard.write(inChar + 1); } } - diff --git a/build/shared/examples/09.USB/KeyboardAndMouseControl/KeyboardAndMouseControl.ino b/build/shared/examples/09.USB/KeyboardAndMouseControl/KeyboardAndMouseControl.ino index f14df1d0fa9..971354134e0 100644 --- a/build/shared/examples/09.USB/KeyboardAndMouseControl/KeyboardAndMouseControl.ino +++ b/build/shared/examples/09.USB/KeyboardAndMouseControl/KeyboardAndMouseControl.ino @@ -1,25 +1,25 @@ - /* KeyboardAndMouseControl - Controls the mouse from five pushbuttons on an Arduino Leonardo, Micro or Due. + Controls the mouse from five pushbuttons on an Arduino Leonardo, Micro or Due. - Hardware: - * 5 pushbuttons attached to D2, D3, D4, D5, D6 + Hardware: + - five pushbuttons attached to D2, D3, D4, D5, D6 - The mouse movement is always relative. This sketch reads - four pushbuttons, and uses them to set the movement of the mouse. + The mouse movement is always relative. This sketch reads four pushbuttons, and + uses them to set the movement of the mouse. - WARNING: When you use the Mouse.move() command, the Arduino takes - over your mouse! Make sure you have control before you use the mouse commands. + WARNING: When you use the Mouse.move() command, the Arduino takes over your + mouse! Make sure you have control before you use the mouse commands. - created 15 Mar 2012 - modified 27 Mar 2012 - by Tom Igoe + created 15 Mar 2012 + modified 27 Mar 2012 + by Tom Igoe - this code is in the public domain + This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/KeyboardAndMouseControl +*/ #include "Keyboard.h" #include "Mouse.h" @@ -91,4 +91,3 @@ void loop() { } } - diff --git a/build/shared/examples/09.USB/Mouse/ButtonMouseControl/ButtonMouseControl.ino b/build/shared/examples/09.USB/Mouse/ButtonMouseControl/ButtonMouseControl.ino index 3b6eef75b82..9c78eda5503 100644 --- a/build/shared/examples/09.USB/Mouse/ButtonMouseControl/ButtonMouseControl.ino +++ b/build/shared/examples/09.USB/Mouse/ButtonMouseControl/ButtonMouseControl.ino @@ -1,28 +1,27 @@ - /* ButtonMouseControl - For Leonardo and Due boards only. - - Controls the mouse from five pushbuttons on an Arduino Leonardo, Micro or Due. + For Leonardo and Due boards only. - Hardware: - * 5 pushbuttons attached to D2, D3, D4, D5, D6 + Controls the mouse from five pushbuttons on an Arduino Leonardo, Micro or Due. + Hardware: + - five pushbuttons attached to D2, D3, D4, D5, D6 - The mouse movement is always relative. This sketch reads - four pushbuttons, and uses them to set the movement of the mouse. + The mouse movement is always relative. This sketch reads four pushbuttons, + and uses them to set the movement of the mouse. - WARNING: When you use the Mouse.move() command, the Arduino takes - over your mouse! Make sure you have control before you use the mouse commands. + WARNING: When you use the Mouse.move() command, the Arduino takes over your + mouse! Make sure you have control before you use the mouse commands. - created 15 Mar 2012 - modified 27 Mar 2012 - by Tom Igoe + created 15 Mar 2012 + modified 27 Mar 2012 + by Tom Igoe - this code is in the public domain + This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/ButtonMouseControl +*/ #include "Mouse.h" diff --git a/build/shared/examples/09.USB/Mouse/JoystickMouseControl/JoystickMouseControl.ino b/build/shared/examples/09.USB/Mouse/JoystickMouseControl/JoystickMouseControl.ino index a147e1b0745..1405322eea7 100644 --- a/build/shared/examples/09.USB/Mouse/JoystickMouseControl/JoystickMouseControl.ino +++ b/build/shared/examples/09.USB/Mouse/JoystickMouseControl/JoystickMouseControl.ino @@ -1,32 +1,33 @@ /* JoystickMouseControl - Controls the mouse from a joystick on an Arduino Leonardo, Micro or Due. - Uses a pushbutton to turn on and off mouse control, and - a second pushbutton to click the left mouse button + Controls the mouse from a joystick on an Arduino Leonardo, Micro or Due. + Uses a pushbutton to turn on and off mouse control, and a second pushbutton + to click the left mouse button. - Hardware: - * 2-axis joystick connected to pins A0 and A1 - * pushbuttons connected to pin D2 and D3 + Hardware: + - 2-axis joystick connected to pins A0 and A1 + - pushbuttons connected to pin D2 and D3 - The mouse movement is always relative. This sketch reads - two analog inputs that range from 0 to 1023 (or less on either end) - and translates them into ranges of -6 to 6. - The sketch assumes that the joystick resting values are around the - middle of the range, but that they vary within a threshold. + The mouse movement is always relative. This sketch reads two analog inputs + that range from 0 to 1023 (or less on either end) and translates them into + ranges of -6 to 6. + The sketch assumes that the joystick resting values are around the middle of + the range, but that they vary within a threshold. - WARNING: When you use the Mouse.move() command, the Arduino takes - over your mouse! Make sure you have control before you use the command. - This sketch includes a pushbutton to toggle the mouse control state, so - you can turn on and off mouse control. + WARNING: When you use the Mouse.move() command, the Arduino takes over your + mouse! Make sure you have control before you use the command. This sketch + includes a pushbutton to toggle the mouse control state, so you can turn on + and off mouse control. - created 15 Sept 2011 - updated 28 Mar 2012 - by Tom Igoe + created 15 Sep 2011 + updated 28 Mar 2012 + by Tom Igoe - this code is in the public domain + This example code is in the public domain. - */ + http://www.arduino.cc/en/Tutorial/JoystickMouseControl +*/ #include "Mouse.h" @@ -96,9 +97,9 @@ void loop() { } /* - reads an axis (0 or 1 for x or y) and scales the - analog input range to a range from 0 to - */ + reads an axis (0 or 1 for x or y) and scales the analog input range to a range + from 0 to +*/ int readAxis(int thisAxis) { // read the analog input: @@ -107,8 +108,7 @@ int readAxis(int thisAxis) { // map the reading from the analog input range to the output range: reading = map(reading, 0, 1023, 0, range); - // if the output reading is outside from the - // rest position threshold, use it: + // if the output reading is outside from the rest position threshold, use it: int distance = reading - center; if (abs(distance) < threshold) { @@ -118,6 +118,3 @@ int readAxis(int thisAxis) { // return the distance for this axis: return distance; } - - - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino b/build/shared/examples/10.StarterKit_BasicKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino index f51a5e22586..41283dad1f3 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino @@ -1,29 +1,27 @@ /* Arduino Starter Kit example - Project 2 - Spaceship Interface + Project 2 - Spaceship Interface - This sketch is written to accompany Project 2 in the - Arduino Starter Kit + This sketch is written to accompany Project 2 in the Arduino Starter Kit - Parts required: - 1 green LED - 2 red LEDs - pushbutton - 10 kilohm resistor - 3 220 ohm resistors + Parts required: + - one green LED + - two red LEDs + - pushbutton + - 10 kilohm resistor + - three 220 ohm resistors - Created 13 September 2012 - by Scott Fitzgerald + created 13 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain + This example code is part of the public domain. */ -// Create a global variable to hold the -// state of the switch. This variable is persistent -// throughout the program. Whenever you refer to -// switchState, you’re talking about the number it holds +// Create a global variable to hold the state of the switch. This variable is +// persistent throughout the program. Whenever you refer to switchState, you’re +// talking about the number it holds int switchstate = 0; void setup() { @@ -39,20 +37,18 @@ void setup() { void loop() { // read the value of the switch - // digitalRead() checks to see if there is voltage - // on the pin or not + // digitalRead() checks to see if there is voltage on the pin or not switchstate = digitalRead(2); - // if the button is not pressed - // turn on the green LED and off the red LEDs + // if the button is not pressed turn on the green LED and off the red LEDs if (switchstate == LOW) { digitalWrite(3, HIGH); // turn the green LED on pin 3 on digitalWrite(4, LOW); // turn the red LED on pin 4 off digitalWrite(5, LOW); // turn the red LED on pin 5 off } // this else is part of the above if() statement. - // if the switch is not LOW (the button is pressed) - // turn off the green LED and blink alternatively the red LEDs + // if the switch is not LOW (the button is pressed) turn off the green LED and + // blink alternatively the red LEDs else { digitalWrite(3, LOW); // turn the green LED on pin 3 off digitalWrite(4, LOW); // turn the red LED on pin 4 off @@ -65,4 +61,3 @@ void loop() { delay(250); } } - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p03_LoveOMeter/p03_LoveOMeter.ino b/build/shared/examples/10.StarterKit_BasicKit/p03_LoveOMeter/p03_LoveOMeter.ino index b00e3fe4862..2a72f46d7f3 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p03_LoveOMeter/p03_LoveOMeter.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p03_LoveOMeter/p03_LoveOMeter.ino @@ -1,26 +1,25 @@ /* Arduino Starter Kit example - Project 3 - Love-O-Meter + Project 3 - Love-O-Meter - This sketch is written to accompany Project 3 in the - Arduino Starter Kit + This sketch is written to accompany Project 3 in the Arduino Starter Kit - Parts required: - 1 TMP36 temperature sensor - 3 red LEDs - 3 220 ohm resistors + Parts required: + - one TMP36 temperature sensor + - three red LEDs + - three 220 ohm resistors - Created 13 September 2012 - by Scott Fitzgerald + created 13 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ // named constant for the pin the sensor is connected to const int sensorPin = A0; -// room temperature in Celcius +// room temperature in Celsius const float baselineTemp = 20.0; void setup() { @@ -35,8 +34,7 @@ void setup() { } void loop() { - // read the value on AnalogIn pin 0 - // and store it in a variable + // read the value on AnalogIn pin 0 and store it in a variable int sensorVal = analogRead(sensorPin); // send the 10-bit sensor value out the serial port @@ -53,13 +51,12 @@ void loop() { // convert the voltage to temperature in degrees C // the sensor changes 10 mV per degree // the datasheet says there's a 500 mV offset - // ((volatge - 500mV) times 100) + // ((voltage - 500 mV) times 100) Serial.print(", degrees C: "); float temperature = (voltage - .5) * 100; Serial.println(temperature); - // if the current temperature is lower than the baseline - // turn off all LEDs + // if the current temperature is lower than the baseline turn off all LEDs if (temperature < baselineTemp + 2) { digitalWrite(2, LOW); digitalWrite(3, LOW); diff --git a/build/shared/examples/10.StarterKit_BasicKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino b/build/shared/examples/10.StarterKit_BasicKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino index d3229f2adda..1e15f1cb377 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino @@ -1,26 +1,25 @@ /* Arduino Starter Kit example - Project 4 - Color Mixing Lamp + Project 4 - Color Mixing Lamp - This sketch is written to accompany Project 3 in the - Arduino Starter Kit + This sketch is written to accompany Project 3 in the Arduino Starter Kit - Parts required: - 1 RGB LED - three 10 kilohm resistors - 3 220 ohm resistors - 3 photoresistors - red green and blue colored gels + Parts required: + - one RGB LED + - three 10 kilohm resistors + - three 220 ohm resistors + - three photoresistors + - red green and blue colored gels - Created 13 September 2012 - Modified 14 November 2012 - by Scott Fitzgerald - Thanks to Federico Vanzati for improvements + created 13 Sep 2012 + modified 14 Nov 2012 + by Scott Fitzgerald + Thanks to Federico Vanzati for improvements - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ const int greenLEDPin = 9; // LED connected to digital pin 9 const int redLEDPin = 10; // LED connected to digital pin 10 @@ -62,7 +61,7 @@ void loop() { // read the value from the blue-filtered photoresistor: blueSensorValue = analogRead(blueSensorPin); - // print out the values to the serial monitor + // print out the values to the Serial Monitor Serial.print("raw sensor Values \t red: "); Serial.print(redSensorValue); Serial.print("\t green: "); @@ -71,16 +70,16 @@ void loop() { Serial.println(blueSensorValue); /* - In order to use the values from the sensor for the LED, - you need to do some math. The ADC provides a 10-bit number, - but analogWrite() uses 8 bits. You'll want to divide your - sensor readings by 4 to keep them in range of the output. + In order to use the values from the sensor for the LED, you need to do some + math. The ADC provides a 10-bit number, but analogWrite() uses 8 bits. + You'll want to divide your sensor readings by 4 to keep them in range + of the output. */ redValue = redSensorValue / 4; greenValue = greenSensorValue / 4; blueValue = blueSensorValue / 4; - // print out the mapped values + // print out the mapped values Serial.print("Mapped sensor Values \t red: "); Serial.print(redValue); Serial.print("\t green: "); @@ -89,10 +88,9 @@ void loop() { Serial.println(blueValue); /* - Now that you have a usable value, it's time to PWM the LED. + Now that you have a usable value, it's time to PWM the LED. */ analogWrite(redLEDPin, redValue); analogWrite(greenLEDPin, greenValue); analogWrite(blueLEDPin, blueValue); } - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p05_ServoMoodIndicator/p05_ServoMoodIndicator.ino b/build/shared/examples/10.StarterKit_BasicKit/p05_ServoMoodIndicator/p05_ServoMoodIndicator.ino index 075555dfee9..b56e860ef99 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p05_ServoMoodIndicator/p05_ServoMoodIndicator.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p05_ServoMoodIndicator/p05_ServoMoodIndicator.ino @@ -1,24 +1,23 @@ /* Arduino Starter Kit example - Project 5 - Servo Mood Indicator + Project 5 - Servo Mood Indicator - This sketch is written to accompany Project 5 in the - Arduino Starter Kit + This sketch is written to accompany Project 5 in the Arduino Starter Kit - Parts required: - servo motor - 10 kilohm potentiometer - 2 100 uF electrolytic capacitors + Parts required: + - servo motor + - 10 kilohm potentiometer + - two 100 uF electrolytic capacitors - Created 13 September 2012 - by Scott Fitzgerald + created 13 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ -// include the servo library +// include the Servo library #include Servo myServo; // create a servo object @@ -34,7 +33,7 @@ void setup() { void loop() { potVal = analogRead(potPin); // read the value of the potentiometer - // print out the value to the serial monitor + // print out the value to the Serial Monitor Serial.print("potVal: "); Serial.print(potVal); @@ -51,5 +50,3 @@ void loop() { // wait for the servo to get there delay(15); } - - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p06_LightTheremin/p06_LightTheremin.ino b/build/shared/examples/10.StarterKit_BasicKit/p06_LightTheremin/p06_LightTheremin.ino index f0c8c2570f5..6f6475c24f7 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p06_LightTheremin/p06_LightTheremin.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p06_LightTheremin/p06_LightTheremin.ino @@ -1,21 +1,20 @@ /* Arduino Starter Kit example - Project 6 - Light Theremin + Project 6 - Light Theremin - This sketch is written to accompany Project 6 in the - Arduino Starter Kit + This sketch is written to accompany Project 6 in the Arduino Starter Kit - Parts required: - photoresistor - 10 kilohm resistor - piezo + Parts required: + - photoresistor + - 10 kilohm resistor + - piezo - Created 13 September 2012 - by Scott Fitzgerald + created 13 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain + This example code is part of the public domain. */ // variable to hold sensor value @@ -61,4 +60,3 @@ void loop() { // wait for a moment delay(10); } - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p07_Keyboard/p07_Keyboard.ino b/build/shared/examples/10.StarterKit_BasicKit/p07_Keyboard/p07_Keyboard.ino index ba913f25c2d..ad39bd19892 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p07_Keyboard/p07_Keyboard.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p07_Keyboard/p07_Keyboard.ino @@ -1,28 +1,26 @@ /* Arduino Starter Kit example - Project 7 - Keyboard + Project 7 - Keyboard - This sketch is written to accompany Project 7 in the - Arduino Starter Kit + This sketch is written to accompany Project 7 in the Arduino Starter Kit - Parts required: - two 10 kilohm resistors - 1 Megohm resistor - 220 ohm resistor - 4 pushbuttons - piezo + Parts required: + - two 10 kilohm resistors + - 1 megohm resistor + - 220 ohm resistor + - four pushbuttons + - piezo - Created 13 September 2012 - by Scott Fitzgerald + created 13 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain + This example code is part of the public domain. */ // create an array of notes -// the numbers below correspond to -// the frequencies of middle C, D, E, and F +// the numbers below correspond to the frequencies of middle C, D, E, and F int notes[] = {262, 294, 330, 349}; void setup() { @@ -54,4 +52,3 @@ void loop() { noTone(8); } } - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p08_DigitalHourglass/p08_DigitalHourglass.ino b/build/shared/examples/10.StarterKit_BasicKit/p08_DigitalHourglass/p08_DigitalHourglass.ino index 932d737f713..801f8cd4110 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p08_DigitalHourglass/p08_DigitalHourglass.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p08_DigitalHourglass/p08_DigitalHourglass.ino @@ -1,23 +1,22 @@ /* Arduino Starter Kit example - Project 8 - Digital Hourglass + Project 8 - Digital Hourglass - This sketch is written to accompany Project 8 in the - Arduino Starter Kit + This sketch is written to accompany Project 8 in the Arduino Starter Kit - Parts required: - 10 kilohm resistor - six 220 ohm resistors - six LEDs - tilt switch + Parts required: + - 10 kilohm resistor + - six 220 ohm resistors + - six LEDs + - tilt switch - Created 13 September 2012 - by Scott Fitzgerald + created 13 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ // named constant for the switch pin const int switchPin = 8; diff --git a/build/shared/examples/10.StarterKit_BasicKit/p09_MotorizedPinwheel/p09_MotorizedPinwheel.ino b/build/shared/examples/10.StarterKit_BasicKit/p09_MotorizedPinwheel/p09_MotorizedPinwheel.ino index 3c89a6ae40d..23e19b1bc8f 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p09_MotorizedPinwheel/p09_MotorizedPinwheel.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p09_MotorizedPinwheel/p09_MotorizedPinwheel.ino @@ -1,25 +1,24 @@ /* Arduino Starter Kit example - Project 9 - Motorized Pinwheel + Project 9 - Motorized Pinwheel - This sketch is written to accompany Project 9 in the - Arduino Starter Kit + This sketch is written to accompany Project 9 in the Arduino Starter Kit - Parts required: - 10 kilohm resistor - pushbutton - motor - 9V battery - IRF520 MOSFET - 1N4007 diode + Parts required: + - 10 kilohm resistor + - pushbutton + - motor + - 9V battery + - IRF520 MOSFET + - 1N4007 diode - Created 13 September 2012 - by Scott Fitzgerald + created 13 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ // named constants for the switch and motor pins const int switchPin = 2; // the number of the switch pin diff --git a/build/shared/examples/10.StarterKit_BasicKit/p10_Zoetrope/p10_Zoetrope.ino b/build/shared/examples/10.StarterKit_BasicKit/p10_Zoetrope/p10_Zoetrope.ino index 44d13ba637b..4d675ed6609 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p10_Zoetrope/p10_Zoetrope.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p10_Zoetrope/p10_Zoetrope.ino @@ -1,26 +1,25 @@ /* Arduino Starter Kit example - Project 10 - Zoetrope + Project 10 - Zoetrope - This sketch is written to accompany Project 10 in the - Arduino Starter Kit + This sketch is written to accompany Project 10 in the Arduino Starter Kit - Parts required: - two 10 kilohm resistors - 2 momentary pushbuttons - one 10 kilohm potentiometer - motor - 9V battery - H-Bridge + Parts required: + - two 10 kilohm resistors + - two momentary pushbuttons + - one 10 kilohm potentiometer + - motor + - 9V battery + - H-Bridge - Created 13 September 2012 - by Scott Fitzgerald - Thanks to Federico Vanzati for improvements + created 13 Sep 2012 + by Scott Fitzgerald + Thanks to Federico Vanzati for improvements - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ const int controlPin1 = 2; // connected to pin 7 on the H-bridge const int controlPin2 = 3; // connected to pin 2 on the H-bridge @@ -30,7 +29,7 @@ const int onOffSwitchStateSwitchPin = 5; // connected to the switch for turning const int potPin = A0; // connected to the potentiometer's output // create some variables to hold values from your inputs -int onOffSwitchState = 0; // current state of the On/Off switch +int onOffSwitchState = 0; // current state of the on/off switch int previousOnOffSwitchState = 0; // previous position of the on/off switch int directionSwitchState = 0; // current state of the direction switch int previousDirectionSwitchState = 0; // previous state of the direction switch @@ -40,7 +39,7 @@ int motorSpeed = 0; // speed of the motor int motorDirection = 1; // current direction of the motor void setup() { - // intialize the inputs and outputs + // initialize the inputs and outputs pinMode(directionSwitchPin, INPUT); pinMode(onOffSwitchStateSwitchPin, INPUT); pinMode(controlPin1, OUTPUT); @@ -59,8 +58,8 @@ void loop() { // read the value of the direction switch directionSwitchState = digitalRead(directionSwitchPin); - // read the value of the pot and divide by 4 to get - // a value that can be used for PWM + // read the value of the pot and divide by 4 to get a value that can be + // used for PWM motorSpeed = analogRead(potPin) / 4; // if the on/off button changed state since the last loop() @@ -79,8 +78,8 @@ void loop() { } } - // change the direction the motor spins by talking - // to the control pins on the H-Bridge + // change the direction the motor spins by talking to the control pins + // on the H-Bridge if (motorDirection == 1) { digitalWrite(controlPin1, HIGH); digitalWrite(controlPin2, LOW); @@ -97,12 +96,8 @@ void loop() { //turn the motor off analogWrite(enablePin, 0); } - // save the current On/Offswitch state as the previous + // save the current on/off switch state as the previous previousDirectionSwitchState = directionSwitchState; // save the current switch state as the previous previousOnOffSwitchState = onOffSwitchState; } - - - - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p11_CrystalBall/p11_CrystalBall.ino b/build/shared/examples/10.StarterKit_BasicKit/p11_CrystalBall/p11_CrystalBall.ino index f17249be6bc..63aefc4c407 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p11_CrystalBall/p11_CrystalBall.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p11_CrystalBall/p11_CrystalBall.ino @@ -1,25 +1,23 @@ /* Arduino Starter Kit example - Project 11 - Crystal Ball + Project 11 - Crystal Ball - This sketch is written to accompany Project 11 in the - Arduino Starter Kit + This sketch is written to accompany Project 11 in the Arduino Starter Kit - Parts required: - 220 ohm resistor - 10 kilohm resistor - 10 kilohm potentiometer - 16x2 LCD screen - tilt switch + Parts required: + - 220 ohm resistor + - 10 kilohm resistor + - 10 kilohm potentiometer + - 16x2 LCD screen + - tilt switch + created 13 Sep 2012 + by Scott Fitzgerald - Created 13 September 2012 - by Scott Fitzgerald + http://www.arduino.cc/starterKit - http://www.arduino.cc/starterKit - - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ // include the library code: #include @@ -27,13 +25,13 @@ // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); -// set up a constant for the tilt switchPin +// set up a constant for the tilt switch pin const int switchPin = 6; -// variable to hold the value of the switchPin +// variable to hold the value of the switch pin int switchState = 0; -// variable to hold previous value of the switchpin +// variable to hold previous value of the switch pin int prevSwitchState = 0; // a variable to choose which reply from the crystal ball @@ -61,9 +59,8 @@ void loop() { // compare the switchState to its previous state if (switchState != prevSwitchState) { - // if the state has changed from HIGH to LOW - // you know that the ball has been tilted from - // one direction to the other + // if the state has changed from HIGH to LOW you know that the ball has been + // tilted from one direction to the other if (switchState == LOW) { // randomly chose a reply reply = random(8); @@ -76,7 +73,7 @@ void loop() { // move the cursor to the second line lcd.setCursor(0, 1); - // choose a saying to print baed on the value in reply + // choose a saying to print based on the value in reply switch (reply) { case 0: lcd.print("Yes"); @@ -115,4 +112,3 @@ void loop() { // save the current switch state as the last state prevSwitchState = switchState; } - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p12_KnockLock/p12_KnockLock.ino b/build/shared/examples/10.StarterKit_BasicKit/p12_KnockLock/p12_KnockLock.ino index a1bb7e72321..9486725a286 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p12_KnockLock/p12_KnockLock.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p12_KnockLock/p12_KnockLock.ino @@ -1,34 +1,33 @@ /* Arduino Starter Kit example - Project 12 - Knock Lock + Project 12 - Knock Lock - This sketch is written to accompany Project 12 in the - Arduino Starter Kit + This sketch is written to accompany Project 12 in the Arduino Starter Kit - Parts required: - 1 Megohm resistor - 10 kilohm resistor - three 220 ohm resistors - piezo - servo motor - push button - one red LED - one yellow LED - one green LED - 100 uF capacitor + Parts required: + - 1 megohm resistor + - 10 kilohm resistor + - three 220 ohm resistors + - piezo + - servo motor + - push button + - one red LED + - one yellow LED + - one green LED + - 100 uF capacitor - Created 18 September 2012 - by Scott Fitzgerald - Thanks to Federico Vanzati for improvements + created 18 Sep 2012 + by Scott Fitzgerald + Thanks to Federico Vanzati for improvements - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ // import the library #include -// create an instance of the servo library +// create an instance of the Servo library Servo myServo; const int piezo = A0; // pin the piezo is attached to @@ -72,7 +71,7 @@ void setup() { // move the servo to the unlocked position myServo.write(0); - // print status to the serial monitor + // print status to the Serial Monitor Serial.println("the box is unlocked!"); } @@ -146,11 +145,10 @@ void loop() { } } -// this function checks to see if a -// detected knock is within max and min range +// this function checks to see if a detected knock is within max and min range boolean checkForKnock(int value) { - // if the value of the knock is greater than - // the minimum, and larger than the maximum + // if the value of the knock is greater than the minimum, and larger + // than the maximum if (value > quietKnock && value < loudKnock) { // turn the status LED on digitalWrite(yellowLed, HIGH); @@ -171,4 +169,3 @@ boolean checkForKnock(int value) { return false; } } - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p13_TouchSensorLamp/p13_TouchSensorLamp.ino b/build/shared/examples/10.StarterKit_BasicKit/p13_TouchSensorLamp/p13_TouchSensorLamp.ino index 64e3d22ad7b..8f7a28a5b9b 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p13_TouchSensorLamp/p13_TouchSensorLamp.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p13_TouchSensorLamp/p13_TouchSensorLamp.ino @@ -1,30 +1,28 @@ /* Arduino Starter Kit example - Project 13 - Touch Sensor Lamp + Project 13 - Touch Sensor Lamp - This sketch is written to accompany Project 13 in the - Arduino Starter Kit + This sketch is written to accompany Project 13 in the Arduino Starter Kit - Parts required: - 1 Megohm resistor - metal foil or copper mesh - 220 ohm resistor - LED + Parts required: + - 1 megohm resistor + - metal foil or copper mesh + - 220 ohm resistor + - LED - Software required : - CapacitiveSensor library by Paul Badger - http://www.arduino.cc/playground/Main/CapacitiveSensor + Software required : + - CapacitiveSensor library by Paul Badger + http://www.arduino.cc/playground/Main/CapacitiveSensor - Created 18 September 2012 - by Scott Fitzgerald + created 18 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ -// import the library (must be located in the -// Arduino/libraries directory) +// import the library (must be located in the Arduino/libraries directory) #include // create an instance of the library @@ -66,6 +64,3 @@ void loop() { delay(10); } - - - diff --git a/build/shared/examples/10.StarterKit_BasicKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino b/build/shared/examples/10.StarterKit_BasicKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino index 2173f6eec7f..e9279e2d61a 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino @@ -1,24 +1,23 @@ /* Arduino Starter Kit example - Project 14 - Tweak the Arduino Logo + Project 14 - Tweak the Arduino Logo - This sketch is written to accompany Project 14 in the - Arduino Starter Kit + This sketch is written to accompany Project 14 in the Arduino Starter Kit - Parts required: - 10 kilohm potentiometer + Parts required: + - 10 kilohm potentiometer - Software required : - Processing (3.0 or newer) http://processing.org - Active internet connection + Software required: + - Processing (3.0 or newer) http://processing.org + - Active Internet connection - Created 18 September 2012 - by Scott Fitzgerald + created 18 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ void setup() { @@ -27,76 +26,76 @@ void setup() { } void loop() { - // read the value of A0, divide by 4 and - // send it as a byte over the serial connection + // read the value of A0, divide by 4 and send it as a byte over the + // serial connection Serial.write(analogRead(A0) / 4); delay(1); } /* Processing code for this example -// Tweak the Arduno Logo -// by Scott Fitzgerald -// This example code is in the public domain -// import the serial library -import processing.serial.*; + // Tweak the Arduino Logo -// create an instance of the serial library -Serial myPort; + // by Scott Fitzgerald + // This example code is in the public domain. -// create an instance of PImage -PImage logo; + // import the serial library + import processing.serial.*; -// a variable to hold the background color -int bgcolor = 0; + // create an instance of the serial library + Serial myPort; -void setup() { - size(1, 1); - surface.setResizable(true); - // set the color mode to Hue/Saturation/Brightness - colorMode(HSB, 255); - - // load the Arduino logo into the PImage instance - logo = loadImage("http://www.arduino.cc/arduino_logo.png"); - - // make the window the same size as the image - surface.setSize(logo.width, logo.height); - - // print a list of available serial ports to the - // Processing staus window - println("Available serial ports:"); - println(Serial.list()); - - // Tell the serial object the information it needs to communicate - // with the Arduno. Change Serial.list()[0] to the correct - // port corresponding to your Arduino board. The last - // parameter (e.g. 9600) is the speed of the communication. It - // has to correspond to the value passed to Serial.begin() in your - // Arduino sketch. - myPort = new Serial(this, Serial.list()[0], 9600); - - // If you know the name of the port used by the Arduino board, you - // can specify it directly like this. - // port = new Serial(this, "COM1", 9600); -} + // create an instance of PImage + PImage logo; + + // a variable to hold the background color + int bgcolor = 0; + + void setup() { + size(1, 1); + surface.setResizable(true); + // set the color mode to Hue/Saturation/Brightness + colorMode(HSB, 255); + + // load the Arduino logo into the PImage instance + logo = loadImage("http://www.arduino.cc/arduino_logo.png"); + + // make the window the same size as the image + surface.setSize(logo.width, logo.height); -void draw() { + // print a list of available serial ports to the Processing status window + println("Available serial ports:"); + println(Serial.list()); - // if there is information in the serial port - if ( myPort.available() > 0) { - // read the value and store it in a variable - bgcolor = myPort.read(); + // Tell the serial object the information it needs to communicate with the + // Arduino. Change Serial.list()[0] to the correct port corresponding to + // your Arduino board. The last parameter (e.g. 9600) is the speed of the + // communication. It has to correspond to the value passed to + // Serial.begin() in your Arduino sketch. + myPort = new Serial(this, Serial.list()[0], 9600); - // print the value to the status window - println(bgcolor); + // If you know the name of the port used by the Arduino board, you can + // specify it directly like this. + // port = new Serial(this, "COM1", 9600); } - // Draw the background. the variable bgcolor - // contains the Hue, determined by the value - // from the serial port - background(bgcolor, 255, 255); + void draw() { - // draw the Arduino logo - image(logo, 0, 0); -} - */ + // if there is information in the serial port + if ( myPort.available() > 0) { + // read the value and store it in a variable + bgcolor = myPort.read(); + + // print the value to the status window + println(bgcolor); + } + + // Draw the background. the variable bgcolor contains the Hue, determined by + // the value from the serial port + background(bgcolor, 255, 255); + + // draw the Arduino logo + image(logo, 0, 0); + } + +*/ diff --git a/build/shared/examples/10.StarterKit_BasicKit/p15_HackingButtons/p15_HackingButtons.ino b/build/shared/examples/10.StarterKit_BasicKit/p15_HackingButtons/p15_HackingButtons.ino index 73d52234bc8..d5d530a2bd2 100644 --- a/build/shared/examples/10.StarterKit_BasicKit/p15_HackingButtons/p15_HackingButtons.ino +++ b/build/shared/examples/10.StarterKit_BasicKit/p15_HackingButtons/p15_HackingButtons.ino @@ -1,22 +1,21 @@ /* Arduino Starter Kit example - Project 15 - Hacking Buttons + Project 15 - Hacking Buttons - This sketch is written to accompany Project 15 in the - Arduino Starter Kit + This sketch is written to accompany Project 15 in the Arduino Starter Kit - Parts required: - batery powered component - 220 ohm resistor - 4N35 optocoupler + Parts required: + - battery powered component + - 220 ohm resistor + - 4N35 optocoupler - Created 18 September 2012 - by Scott Fitzgerald + created 18 Sep 2012 + by Scott Fitzgerald - http://www.arduino.cc/starterKit + http://www.arduino.cc/starterKit - This example code is part of the public domain - */ + This example code is part of the public domain. +*/ const int optoPin = 2; // the pin the optocoupler is connected to @@ -33,5 +32,3 @@ void loop() { digitalWrite(optoPin, LOW); // pull pin 2 low until you're ready to activate again delay(21000); // wait for 21 seconds } - - diff --git a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino index d4fd37ea5cc..8caa58eabe1 100644 --- a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -1,32 +1,32 @@ // ArduinoISP // Copyright (c) 2008-2011 Randall Bohn // If you require a license, see -// http://www.opensource.org/licenses/bsd-license.php +// http://www.opensource.org/licenses/bsd-license.php // -// This sketch turns the Arduino into a AVRISP -// using the following arduino pins: +// This sketch turns the Arduino into a AVRISP using the following Arduino pins: // // Pin 10 is used to reset the target microcontroller. // -// By default, the hardware SPI pins MISO, MOSI and SCK pins are used -// to communicate with the target. On all Arduinos, these pins can be found +// By default, the hardware SPI pins MISO, MOSI and SCK are used to communicate +// with the target. On all Arduinos, these pins can be found // on the ICSP/SPI header: // // MISO °. . 5V (!) Avoid this pin on Due, Zero... // SCK . . MOSI // . . GND // -// On some Arduinos (Uno,...), pins MOSI, MISO and SCK are the same pins -// as digital pin 11, 12 and 13, respectively. That is why many tutorials -// instruct you to hook up the target to these pins. If you find this wiring -// more practical, have a define USE_OLD_STYLE_WIRING. This will work even -// even when not using an Uno. (On an Uno this is not needed). +// On some Arduinos (Uno,...), pins MOSI, MISO and SCK are the same pins as +// digital pin 11, 12 and 13, respectively. That is why many tutorials instruct +// you to hook up the target to these pins. If you find this wiring more +// practical, have a define USE_OLD_STYLE_WIRING. This will work even when not +// using an Uno. (On an Uno this is not needed). // -// Alternatively you can use any other digital pin by configuring software ('BitBanged') -// SPI and having appropriate defines for PIN_MOSI, PIN_MISO and PIN_SCK. -// -// IMPORTANT: When using an Arduino that is not 5V tolerant (Due, Zero, ...) -// as the programmer, make sure to not expose any of the programmer's pins to 5V. +// Alternatively you can use any other digital pin by configuring +// software ('BitBanged') SPI and having appropriate defines for PIN_MOSI, +// PIN_MISO and PIN_SCK. +// +// IMPORTANT: When using an Arduino that is not 5V tolerant (Due, Zero, ...) as +// the programmer, make sure to not expose any of the programmer's pins to 5V. // A simple way to accomplish this is to power the complete system (programmer // and target) at 3V3. // @@ -43,19 +43,19 @@ #define PROG_FLICKER true // Configure SPI clock (in Hz). -// E.g. for an attiny @128 kHz: the datasheet states that both the high -// and low spi clock pulse must be > 2 cpu cycles, so take 3 cycles i.e. -// divide target f_cpu by 6: +// E.g. for an ATtiny @ 128 kHz: the datasheet states that both the high and low +// SPI clock pulse must be > 2 CPU cycles, so take 3 cycles i.e. divide target +// f_cpu by 6: // #define SPI_CLOCK (128000/6) // -// A clock slow enough for an attiny85 @ 1MHz, is a reasonable default: +// A clock slow enough for an ATtiny85 @ 1 MHz, is a reasonable default: #define SPI_CLOCK (1000000/6) // Select hardware or software SPI, depending on SPI clock. -// Currently only for AVR, for other archs (Due, Zero,...), -// hardware SPI is probably too fast anyway. +// Currently only for AVR, for other architectures (Due, Zero,...), hardware SPI +// is probably too fast anyway. #if defined(ARDUINO_ARCH_AVR) @@ -68,7 +68,7 @@ // Configure which pins to use: // The standard pin configuration. -#ifndef ARDUINO_HOODLOADER2 +#ifndef ARDUINO_HOODLOADER2 #define RESET 10 // Use pin 10 to reset the target rather than SS #define LED_HB 9 @@ -88,10 +88,9 @@ #endif -// HOODLOADER2 means running sketches on the atmega16u2 -// serial converter chips on Uno or Mega boards. -// We must use pins that are broken out: -#else +// HOODLOADER2 means running sketches on the ATmega16U2 serial converter chips +// on Uno or Mega boards. We must use pins that are broken out: +#else #define RESET 4 #define LED_HB 7 @@ -166,51 +165,51 @@ void pulse(int pin, int times); #define SPI_MODE0 0x00 class SPISettings { -public: - // clock is in Hz - SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) : clock(clock){ - (void) bitOrder; - (void) dataMode; - }; + public: + // clock is in Hz + SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) : clock(clock) { + (void) bitOrder; + (void) dataMode; + }; -private: - uint32_t clock; + private: + uint32_t clock; -friend class BitBangedSPI; + friend class BitBangedSPI; }; class BitBangedSPI { -public: - void begin() { - digitalWrite(PIN_SCK, LOW); - digitalWrite(PIN_MOSI, LOW); - pinMode(PIN_SCK, OUTPUT); - pinMode(PIN_MOSI, OUTPUT); - pinMode(PIN_MISO, INPUT); - } + public: + void begin() { + digitalWrite(PIN_SCK, LOW); + digitalWrite(PIN_MOSI, LOW); + pinMode(PIN_SCK, OUTPUT); + pinMode(PIN_MOSI, OUTPUT); + pinMode(PIN_MISO, INPUT); + } - void beginTransaction(SPISettings settings) { - pulseWidth = (500000 + settings.clock - 1) / settings.clock; - if (pulseWidth == 0) - pulseWidth = 1; - } + void beginTransaction(SPISettings settings) { + pulseWidth = (500000 + settings.clock - 1) / settings.clock; + if (pulseWidth == 0) + pulseWidth = 1; + } - void end() {} + void end() {} - uint8_t transfer (uint8_t b) { - for (unsigned int i = 0; i < 8; ++i) { - digitalWrite(PIN_MOSI, (b & 0x80) ? HIGH : LOW); - digitalWrite(PIN_SCK, HIGH); - delayMicroseconds(pulseWidth); - b = (b << 1) | digitalRead(PIN_MISO); - digitalWrite(PIN_SCK, LOW); // slow pulse - delayMicroseconds(pulseWidth); + uint8_t transfer (uint8_t b) { + for (unsigned int i = 0; i < 8; ++i) { + digitalWrite(PIN_MOSI, (b & 0x80) ? HIGH : LOW); + digitalWrite(PIN_SCK, HIGH); + delayMicroseconds(pulseWidth); + b = (b << 1) | digitalRead(PIN_MISO); + digitalWrite(PIN_SCK, LOW); // slow pulse + delayMicroseconds(pulseWidth); + } + return b; } - return b; - } -private: - unsigned long pulseWidth; // in microseconds + private: + unsigned long pulseWidth; // in microseconds }; static BitBangedSPI SPI; @@ -371,7 +370,7 @@ void get_version(uint8_t c) { } void set_parameters() { - // call this after reading paramter packet into buff[] + // call this after reading parameter packet into buff[] param.devicecode = buff[0]; param.revision = buff[1]; param.progtype = buff[2]; @@ -393,7 +392,7 @@ void set_parameters() { + buff[18] * 0x00000100 + buff[19]; - // avr devices have active low reset, at89sx are active high + // AVR devices have active low reset, AT89Sx are active high rst_active_high = (param.devicecode >= 0xe0); } @@ -401,10 +400,8 @@ void start_pmode() { // Reset target before driving PIN_SCK or PIN_MOSI - // SPI.begin() will configure SS as output, - // so SPI master mode is selected. - // We have defined RESET as pin 10, - // which for many arduino's is not the SS pin. + // SPI.begin() will configure SS as output, so SPI master mode is selected. + // We have defined RESET as pin 10, which for many Arduinos is not the SS pin. // So we have to configure RESET as output here, // (reset_target() first sets the correct level) reset_target(true); @@ -412,14 +409,14 @@ void start_pmode() { SPI.begin(); SPI.beginTransaction(SPISettings(SPI_CLOCK, MSBFIRST, SPI_MODE0)); - // See avr datasheets, chapter "SERIAL_PRG Programming Algorithm": + // See AVR datasheets, chapter "SERIAL_PRG Programming Algorithm": // Pulse RESET after PIN_SCK is low: digitalWrite(PIN_SCK, LOW); - delay(20); // discharge PIN_SCK, value arbitrally chosen + delay(20); // discharge PIN_SCK, value arbitrarily chosen reset_target(false); - // Pulse must be minimum 2 target CPU clock cycles - // so 100 usec is ok for CPU speeds above 20KHz + // Pulse must be minimum 2 target CPU clock cycles so 100 usec is ok for CPU + // speeds above 20 KHz delayMicroseconds(100); reset_target(true); @@ -431,8 +428,7 @@ void start_pmode() { void end_pmode() { SPI.end(); - // We're about to take the target out of reset - // so configure SPI pins as input + // We're about to take the target out of reset so configure SPI pins as input pinMode(PIN_MOSI, INPUT); pinMode(PIN_SCK, INPUT); reset_target(false); @@ -530,8 +526,7 @@ uint8_t write_eeprom(unsigned int length) { } // write (length) bytes, (start) is a byte address uint8_t write_eeprom_chunk(unsigned int start, unsigned int length) { - // this writes byte-by-byte, - // page writing may be faster (4 bytes at a time) + // this writes byte-by-byte, page writing may be faster (4 bytes at a time) fill(length); prog_lamp(LOW); for (unsigned int x = 0; x < length; x++) { @@ -722,4 +717,3 @@ void avrisp() { SERIAL.print((char)STK_NOSYNC); } } -