diff --git a/build/shared/examples/01.Basics/Blink/Blink.ino b/build/shared/examples/01.Basics/Blink/Blink.ino index aa12be617..b73772542 100644 --- a/build/shared/examples/01.Basics/Blink/Blink.ino +++ b/build/shared/examples/01.Basics/Blink/Blink.ino @@ -6,8 +6,9 @@ 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 + 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 diff --git a/build/shared/examples/01.Basics/Fade/Fade.ino b/build/shared/examples/01.Basics/Fade/Fade.ino index e92a69f9a..744dc4277 100644 --- a/build/shared/examples/01.Basics/Fade/Fade.ino +++ b/build/shared/examples/01.Basics/Fade/Fade.ino @@ -1,14 +1,12 @@ /* 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. diff --git a/build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino b/build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino index 63151027b..c96f3baed 100644 --- a/build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino +++ b/build/shared/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino @@ -1,17 +1,18 @@ /* 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. + 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 + - 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 @@ -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) { diff --git a/build/shared/examples/02.Digital/Button/Button.ino b/build/shared/examples/02.Digital/Button/Button.ino index 955013f15..06cb35189 100644 --- a/build/shared/examples/02.Digital/Button/Button.ino +++ b/build/shared/examples/02.Digital/Button/Button.ino @@ -1,8 +1,8 @@ /* 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 @@ -22,8 +22,7 @@ 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 @@ -41,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); diff --git a/build/shared/examples/02.Digital/Debounce/Debounce.ino b/build/shared/examples/02.Digital/Debounce/Debounce.ino index 875ec1d47..d5d48c918 100644 --- a/build/shared/examples/02.Digital/Debounce/Debounce.ino +++ b/build/shared/examples/02.Digital/Debounce/Debounce.ino @@ -2,17 +2,16 @@ 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). + 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 - 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 @@ -28,8 +27,7 @@ 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 @@ -38,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 longs because the time, measured in milliseconds, -// 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 @@ -56,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) { @@ -66,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) { @@ -83,7 +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 8fc945db3..dc641ac71 100644 --- a/build/shared/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino +++ b/build/shared/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino @@ -1,16 +1,16 @@ /* 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 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. + 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 Mar 2012 by Scott Fitzgerald @@ -35,9 +35,8 @@ void loop() { //print out the value of the pushbutton Serial.println(sensorVal); - // 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 + // 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); diff --git a/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino b/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino index 450896f71..a5ba8dab2 100644 --- a/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino +++ b/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino @@ -1,8 +1,8 @@ /* 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. + 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. @@ -12,8 +12,8 @@ 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) + - 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 @@ -51,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 - // went 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.println(buttonPushCounter); } else { - // if the current state is LOW then the button - // went 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 { diff --git a/build/shared/examples/02.Digital/toneMelody/toneMelody.ino b/build/shared/examples/02.Digital/toneMelody/toneMelody.ino index e8b3371e9..8cc1b53d0 100644 --- a/build/shared/examples/02.Digital/toneMelody/toneMelody.ino +++ b/build/shared/examples/02.Digital/toneMelody/toneMelody.ino @@ -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/tonePitchFollower/tonePitchFollower.ino b/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino index 29ef4a83b..c8d85679c 100644 --- a/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino +++ b/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino @@ -29,8 +29,8 @@ 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: diff --git a/build/shared/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino b/build/shared/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino index be925c437..6675a8c88 100644 --- a/build/shared/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino +++ b/build/shared/examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino @@ -1,8 +1,8 @@ /* 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 pulse width modulation (PWM) of an output pin. + 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: @@ -20,8 +20,7 @@ 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 @@ -47,8 +46,7 @@ void loop() { 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 4dfcbe4d8..13e7b5220 100644 --- a/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino +++ b/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino @@ -3,8 +3,8 @@ 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 amount of time the LED will be on and off depends on the value obtained + by analogRead(). The circuit: - potentiometer @@ -15,8 +15,8 @@ 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. + - 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 diff --git a/build/shared/examples/03.Analog/AnalogWriteMega/AnalogWriteMega.ino b/build/shared/examples/03.Analog/AnalogWriteMega/AnalogWriteMega.ino index a0d2eb738..37a62a1fa 100644 --- a/build/shared/examples/03.Analog/AnalogWriteMega/AnalogWriteMega.ino +++ b/build/shared/examples/03.Analog/AnalogWriteMega/AnalogWriteMega.ino @@ -15,8 +15,7 @@ http://www.arduino.cc/en/Tutorial/AnalogWriteMega */ -// 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 lowestPin = 2; const int highestPin = 13; diff --git a/build/shared/examples/03.Analog/Calibration/Calibration.ino b/build/shared/examples/03.Analog/Calibration/Calibration.ino index 82fb8cd56..5c0fc6dfa 100644 --- a/build/shared/examples/03.Analog/Calibration/Calibration.ino +++ b/build/shared/examples/03.Analog/Calibration/Calibration.ino @@ -1,15 +1,14 @@ /* 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 diff --git a/build/shared/examples/03.Analog/Smoothing/Smoothing.ino b/build/shared/examples/03.Analog/Smoothing/Smoothing.ino index dce81524a..5df0d0554 100644 --- a/build/shared/examples/03.Analog/Smoothing/Smoothing.ino +++ b/build/shared/examples/03.Analog/Smoothing/Smoothing.ino @@ -1,9 +1,9 @@ /* 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 @@ -18,10 +18,10 @@ 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 -// us 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 diff --git a/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino b/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino index 6522d7b00..7cf55d03e 100644 --- a/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino +++ b/build/shared/examples/04.Communication/ASCIITable/ASCIITable.ino @@ -37,9 +37,9 @@ int thisByte = 33; // 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: "); @@ -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 f3265ce36..3f2c6fc66 100644 --- a/build/shared/examples/04.Communication/Dimmer/Dimmer.ino +++ b/build/shared/examples/04.Communication/Dimmer/Dimmer.ino @@ -1,10 +1,10 @@ /* Dimmer - 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. + 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. @@ -56,15 +56,14 @@ void loop() { // 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. + // 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. + // 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); } diff --git a/build/shared/examples/04.Communication/Graph/Graph.ino b/build/shared/examples/04.Communication/Graph/Graph.ino index 13e6c6a72..4aaf8d689 100644 --- a/build/shared/examples/04.Communication/Graph/Graph.ino +++ b/build/shared/examples/04.Communication/Graph/Graph.ino @@ -1,17 +1,16 @@ /* 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" + 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. + 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 attached to analog in pin 0 @@ -34,8 +33,8 @@ 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); } @@ -44,9 +43,9 @@ void loop() { // 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 @@ -67,8 +66,8 @@ void loop() { // 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]. + // 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); diff --git a/build/shared/examples/04.Communication/Midi/Midi.ino b/build/shared/examples/04.Communication/Midi/Midi.ino index 1be5b7d7e..5ef34062c 100644 --- a/build/shared/examples/04.Communication/Midi/Midi.ino +++ b/build/shared/examples/04.Communication/Midi/Midi.ino @@ -2,8 +2,8 @@ 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. + 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 @@ -37,8 +37,8 @@ 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); diff --git a/build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino b/build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino index a64376d22..16ee3731d 100644 --- a/build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino +++ b/build/shared/examples/04.Communication/PhysicalPixel/PhysicalPixel.ino @@ -1,14 +1,12 @@ /* 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 @@ -53,9 +51,8 @@ void loop() { // 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 @@ -81,9 +78,9 @@ void loop() { 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. + // 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()); diff --git a/build/shared/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino b/build/shared/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino index e3ff79155..ab26c282a 100644 --- a/build/shared/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino +++ b/build/shared/examples/04.Communication/ReadASCIIString/ReadASCIIString.ino @@ -45,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);" diff --git a/build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino b/build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino index 1fedbaab4..6b0aa8336 100644 --- a/build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino +++ b/build/shared/examples/04.Communication/SerialCallResponse/SerialCallResponse.ino @@ -2,9 +2,8 @@ Serial Call and Response 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 + 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. The circuit: @@ -92,8 +91,8 @@ void establishContact() { // 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]. + // 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]; @@ -110,9 +109,8 @@ void establishContact() { 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. + // 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') { diff --git a/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino b/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino index 76304da61..ef2eac5e6 100644 --- a/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino +++ b/build/shared/examples/04.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino @@ -2,12 +2,10 @@ Serial Call and Response in ASCII 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. + 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 @@ -88,10 +86,10 @@ void establishContact() { // 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. + // 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); // read bytes into a buffer until you get a linefeed (ASCII 10): @@ -108,8 +106,8 @@ void establishContact() { 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() + // 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) { @@ -118,8 +116,7 @@ void establishContact() { // 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: diff --git a/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino b/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino index 4d5bb85c8..43f9eaf4e 100644 --- a/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino +++ b/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino @@ -2,14 +2,13 @@ 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 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. + NOTE: The serialEvent() feature is not available on the Leonardo, Micro, or + other ATmega32U4 based boards. created 9 May 2011 by Tom Igoe @@ -40,10 +39,9 @@ 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()) { @@ -51,8 +49,8 @@ void serialEvent() { 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 0116027ae..81037ebdc 100644 --- a/build/shared/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino +++ b/build/shared/examples/04.Communication/SerialPassthrough/SerialPassthrough.ino @@ -1,23 +1,22 @@ /* 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 diff --git a/build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino b/build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino index 4fd6baa87..cba36eda2 100644 --- a/build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino +++ b/build/shared/examples/04.Communication/VirtualColorMixer/VirtualColorMixer.ino @@ -1,7 +1,7 @@ /* - 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 @@ -51,8 +51,8 @@ void loop() { // 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]. + // 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: @@ -71,12 +71,11 @@ void loop() { 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: + // 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 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); diff --git a/build/shared/examples/05.Control/Arrays/Arrays.ino b/build/shared/examples/05.Control/Arrays/Arrays.ino index a05e8a137..549ac3463 100644 --- a/build/shared/examples/05.Control/Arrays/Arrays.ino +++ b/build/shared/examples/05.Control/Arrays/Arrays.ino @@ -1,12 +1,11 @@ /* 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 diff --git a/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino b/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino index 48ee22de3..4dd40901d 100644 --- a/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino +++ b/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino @@ -3,8 +3,8 @@ 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. + only if the potentiometer goes above a certain threshold level. It prints the + analog value regardless of the level. The circuit: - potentiometer @@ -12,8 +12,8 @@ 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 diff --git a/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino b/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino index 9efda34f3..4f1383f5e 100644 --- a/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino +++ b/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino @@ -4,8 +4,8 @@ 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 photoresistor. + 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. diff --git a/build/shared/examples/05.Control/switchCase/switchCase.ino b/build/shared/examples/05.Control/switchCase/switchCase.ino index 54908a59b..c313f6b98 100644 --- a/build/shared/examples/05.Control/switchCase/switchCase.ino +++ b/build/shared/examples/05.Control/switchCase/switchCase.ino @@ -1,13 +1,12 @@ /* 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, put the board and sensor in a well-lit - room, open the Serial Monitor, 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 @@ -22,8 +21,8 @@ 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"); diff --git a/build/shared/examples/05.Control/switchCase2/switchCase2.ino b/build/shared/examples/05.Control/switchCase2/switchCase2.ino index dbc74b082..c30843f73 100644 --- a/build/shared/examples/05.Control/switchCase2/switchCase2.ino +++ b/build/shared/examples/05.Control/switchCase2/switchCase2.ino @@ -1,13 +1,13 @@ /* 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. + The characters a, b, c, d, and e, will turn on LEDs. Any other character will + turn the LEDs off. The circuit: - five LEDs attached to digital pins 2 through 6 through 220 ohm resistors @@ -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 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: + // 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': diff --git a/build/shared/examples/06.Sensors/ADXL3xx/ADXL3xx.ino b/build/shared/examples/06.Sensors/ADXL3xx/ADXL3xx.ino index bee93c144..1cf4be447 100644 --- a/build/shared/examples/06.Sensors/ADXL3xx/ADXL3xx.ino +++ b/build/shared/examples/06.Sensors/ADXL3xx/ADXL3xx.ino @@ -35,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 9c6160c50..99b50e4de 100644 --- a/build/shared/examples/06.Sensors/Knock/Knock.ino +++ b/build/shared/examples/06.Sensors/Knock/Knock.ino @@ -3,8 +3,8 @@ 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. + If the result is greater than the threshold, it writes "knock" to the serial + port, and toggles the LED on pin 13. The circuit: - positive connection of the piezo attached to analog in 0 diff --git a/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.ino b/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.ino index 6b72836e4..da69df9d1 100644 --- a/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.ino +++ b/build/shared/examples/06.Sensors/Memsic2125/Memsic2125.ino @@ -1,10 +1,9 @@ /* 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 @@ -29,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); } diff --git a/build/shared/examples/06.Sensors/Ping/Ping.ino b/build/shared/examples/06.Sensors/Ping/Ping.ino index da8fc0778..cdde18e45 100644 --- a/build/shared/examples/06.Sensors/Ping/Ping.ino +++ b/build/shared/examples/06.Sensors/Ping/Ping.ino @@ -1,11 +1,10 @@ /* 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 @@ -22,8 +21,7 @@ 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 cf1fa9e30..f2cf79525 100644 --- a/build/shared/examples/07.Display/RowColumnScanning/RowColumnScanning.ino +++ b/build/shared/examples/07.Display/RowColumnScanning/RowColumnScanning.ino @@ -7,8 +7,8 @@ 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 @@ -51,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); } @@ -84,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 aaa0a572c..48327a98b 100644 --- a/build/shared/examples/07.Display/barGraph/barGraph.ino +++ b/build/shared/examples/07.Display/barGraph/barGraph.ino @@ -2,12 +2,12 @@ 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 diff --git a/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino b/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino index 9ab93f707..48540f9cd 100644 --- a/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino +++ b/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino @@ -97,8 +97,8 @@ void loop() { // 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) { diff --git a/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino b/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino index 46b224069..bac9f81ef 100644 --- a/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino +++ b/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino @@ -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); diff --git a/build/shared/examples/08.Strings/StringToInt/StringToInt.ino b/build/shared/examples/08.Strings/StringToInt/StringToInt.ino index 1d4a7ce0e..59e872aa2 100644 --- a/build/shared/examples/08.Strings/StringToInt/StringToInt.ino +++ b/build/shared/examples/08.Strings/StringToInt/StringToInt.ino @@ -1,8 +1,8 @@ /* String to Integer conversion - Reads a serial input string until it sees a newline, then converts - the string to a number if the characters are digits. + Reads a serial input string until it sees a newline, then converts the string + to a number if the characters are digits. The circuit: - No external components needed. @@ -34,12 +34,10 @@ void loop() { while (Serial.available() > 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()); diff --git a/build/shared/examples/09.USB/Keyboard/KeyboardLogout/KeyboardLogout.ino b/build/shared/examples/09.USB/Keyboard/KeyboardLogout/KeyboardLogout.ino index d159af6d5..f6ea490c2 100644 --- a/build/shared/examples/09.USB/Keyboard/KeyboardLogout/KeyboardLogout.ino +++ b/build/shared/examples/09.USB/Keyboard/KeyboardLogout/KeyboardLogout.ino @@ -35,8 +35,7 @@ int platform = OSX; void setup() { - // make pin 2 an input and turn on the - // pull-up 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(); diff --git a/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino b/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino index dc461fac8..7ec0d6d89 100644 --- a/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino +++ b/build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino @@ -5,12 +5,10 @@ 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 @@ -38,8 +36,7 @@ char ctrlKey = KEY_LEFT_GUI; void setup() { - // make pin 2 an input and turn on the - // pull-up 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,9 +57,8 @@ 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 + // 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'); diff --git a/build/shared/examples/09.USB/Keyboard/KeyboardSerial/KeyboardSerial.ino b/build/shared/examples/09.USB/Keyboard/KeyboardSerial/KeyboardSerial.ino index 0e9c7e436..72d9dddf5 100644 --- a/build/shared/examples/09.USB/Keyboard/KeyboardSerial/KeyboardSerial.ino +++ b/build/shared/examples/09.USB/Keyboard/KeyboardSerial/KeyboardSerial.ino @@ -4,8 +4,8 @@ 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. + 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 diff --git a/build/shared/examples/09.USB/KeyboardAndMouseControl/KeyboardAndMouseControl.ino b/build/shared/examples/09.USB/KeyboardAndMouseControl/KeyboardAndMouseControl.ino index a8b6125f8..971354134 100644 --- a/build/shared/examples/09.USB/KeyboardAndMouseControl/KeyboardAndMouseControl.ino +++ b/build/shared/examples/09.USB/KeyboardAndMouseControl/KeyboardAndMouseControl.ino @@ -6,11 +6,11 @@ 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 diff --git a/build/shared/examples/09.USB/Mouse/ButtonMouseControl/ButtonMouseControl.ino b/build/shared/examples/09.USB/Mouse/ButtonMouseControl/ButtonMouseControl.ino index d68b06f40..9c78eda55 100644 --- a/build/shared/examples/09.USB/Mouse/ButtonMouseControl/ButtonMouseControl.ino +++ b/build/shared/examples/09.USB/Mouse/ButtonMouseControl/ButtonMouseControl.ino @@ -8,11 +8,11 @@ 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 diff --git a/build/shared/examples/09.USB/Mouse/JoystickMouseControl/JoystickMouseControl.ino b/build/shared/examples/09.USB/Mouse/JoystickMouseControl/JoystickMouseControl.ino index 72fa47b81..1405322ee 100644 --- a/build/shared/examples/09.USB/Mouse/JoystickMouseControl/JoystickMouseControl.ino +++ b/build/shared/examples/09.USB/Mouse/JoystickMouseControl/JoystickMouseControl.ino @@ -2,23 +2,23 @@ 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. + 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 - 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 Sep 2011 updated 28 Mar 2012 @@ -97,8 +97,8 @@ void loop() { } /* - reads an axis (0 or 1 for x or y) and scales the - analog input range to a range from 0 to