Auto Format all built-in examples

The only changes I left out are the Max/MSP patches because I don't know whether the indentation would break them.
This commit is contained in:
per1234 2017-07-14 15:35:58 -07:00 committed by Cristian Maglie
parent 8f48433f33
commit eee3e5ba18
72 changed files with 128 additions and 128 deletions

View File

@ -2,20 +2,20 @@
Blink
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
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.
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
*/

View File

@ -3,7 +3,7 @@
Reads a digital input on pin 2, prints the result to the Serial Monitor
This example code is in the public domain.
*/
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

View File

@ -7,11 +7,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
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.
*/
*/
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is

View File

@ -6,7 +6,7 @@
The circuit:
- Use the onboard LED.
- Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
- 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
@ -25,7 +25,7 @@
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

View File

@ -22,7 +22,7 @@
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:

View File

@ -28,7 +28,7 @@
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:

View File

@ -19,7 +19,7 @@
This example code is in the public domain
*/
*/
void setup() {
//start serial connection

View File

@ -23,7 +23,7 @@
http://www.arduino.cc/en/Tutorial/ButtonStateChange
*/
*/
// this constant won't change:
const int buttonPin = 2; // the pin that the pushbutton is attached to

View File

@ -16,7 +16,7 @@
http://www.arduino.cc/en/Tutorial/Tone3
*/
*/
#include "pitches.h"

View File

@ -14,7 +14,7 @@
http://www.arduino.cc/en/Tutorial/Tone
*/
*/
#include "pitches.h"
// notes in the melody:

View File

@ -14,7 +14,7 @@
http://www.arduino.cc/en/Tutorial/Tone4
*/
*/
void setup() {

View File

@ -16,7 +16,7 @@
http://www.arduino.cc/en/Tutorial/Tone2
*/
*/
void setup() {

View File

@ -17,7 +17,7 @@
This example code is in the public domain.
*/
*/
// These constants won't change. They're used to give names
// to the pins used:

View File

@ -25,7 +25,7 @@
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

View File

@ -12,7 +12,7 @@
This example code is in the public domain.
*/
*/
// These constants won't change. They're used to give names
// to the pins used:
const int lowestPin = 2;

View File

@ -24,7 +24,7 @@
This example code is in the public domain.
*/
*/
// These constants won't change:
const int sensorPin = A0; // pin that the sensor is attached to

View File

@ -15,7 +15,7 @@
This example code is in the public domain.
*/
*/
int ledPin = 9; // LED connected to digital pin 9

View File

@ -18,7 +18,7 @@
<http://www.zambetti.com>
*/
*/
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);

View File

@ -19,7 +19,7 @@
http://www.arduino.cc/en/Tutorial/Dimmer
*/
*/
const int ledPin = 9; // the pin that the LED is attached to
@ -80,7 +80,7 @@ void loop() {
// a single byte
port.write(mouseX);
}
*/
*/
/* Max/MSP v5 patch for this example

View File

@ -24,7 +24,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Graph
*/
*/
void setup() {
// initialize the serial communication:

View File

@ -20,7 +20,7 @@
http://www.arduino.cc/en/Tutorial/Midi
*/
*/
void setup() {
// Set MIDI baud rate:

View File

@ -18,7 +18,7 @@
This example code is in the public domain.
*/
*/
void setup() {

View File

@ -21,7 +21,7 @@
This example code is in the public domain.
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
@ -121,7 +121,7 @@ void loop() {
}
*/
*/
/*
Max/MSP version 5 patch to run with this example:

View File

@ -13,12 +13,12 @@
created 13 Apr 2012
by Tom Igoe
modified 14 Mar 2016
by Arturo Guadalupi
This example code is in the public domain.
*/
*/
// pins for the LEDs:
const int redPin = 3;

View File

@ -22,7 +22,7 @@
http://www.arduino.cc/en/Tutorial/SerialCallResponse
*/
*/
int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor

View File

@ -26,7 +26,7 @@
http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII
*/
*/
int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor

View File

@ -10,7 +10,7 @@
NOTE: The serialEvent() feature is not available on the
Leonardo, Micro, or other ATmega32U4 based boards.
Created 9 May 2011
by Tom Igoe
@ -18,7 +18,7 @@
http://www.arduino.cc/en/Tutorial/SerialEvent
*/
*/
String inputString = ""; // a String to hold incoming data
boolean stringComplete = false; // whether the string is complete
@ -45,7 +45,7 @@ void loop() {
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:

View File

@ -14,7 +14,7 @@
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
*/
*/
const int redPin = A0; // sensor to control red color
const int greenPin = A1; // sensor to control green color
@ -86,7 +86,7 @@ void loop() {
}
}
*/
*/
/* Max/MSP patch for this example

View File

@ -19,7 +19,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Array
*/
*/
int timer = 100; // The higher the number, the slower the timing.
int ledPins[] = {

View File

@ -15,7 +15,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/ForLoop
*/
*/
int timer = 100; // The higher the number, the slower the timing.

View File

@ -23,7 +23,7 @@
http://www.arduino.cc/en/Tutorial/IfStatement
*/
*/
// These constants won't change:
const int analogPin = A0; // pin that the sensor is attached to

View File

@ -26,7 +26,7 @@
http://www.arduino.cc/en/Tutorial/WhileLoop
*/
*/
// These constants won't change:

View File

@ -20,7 +20,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/SwitchCase
*/
*/
// these constants won't change. They are the
// lowest and highest readings you get from your sensor:

View File

@ -18,7 +18,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/SwitchCase2
*/
*/
void setup() {
// initialize serial communication:

View File

@ -19,7 +19,7 @@
This example code is in the public domain.
*/
*/
// these constants won't change:

View File

@ -21,7 +21,7 @@
This example code is in the public domain.
*/
*/
// these constants won't change:
const int xPin = 2; // X output of the accelerometer

View File

@ -20,7 +20,7 @@
This example code is in the public domain.
*/
*/
// this constant won't change. It's the pin number
// of the sensor's output:

View File

@ -31,7 +31,7 @@
http://www.arduino.cc/en/Tutorial/RowColumnScanning
see also http://www.tigoe.net/pcomp/code/category/arduinowiring/514 for more
*/
*/
// 2-dimensional array of row pin numbers:

View File

@ -18,7 +18,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/BarGraph
*/
*/
// these constants won't change:

View File

@ -9,7 +9,7 @@
by Tom Igoe
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -11,7 +11,7 @@
http://www.arduino.cc/en/Tutorial/StringAdditionOperator
This example code is in the public domain.
*/
*/
// declare three Strings:
String stringOne, stringTwo, stringThree;

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringAppendOperator
This example code is in the public domain.
*/
*/
String stringOne, stringTwo;

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringCaseChanges
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringCharacters
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringComparisonOperators
This example code is in the public domain.
*/
*/
String stringOne, stringTwo;

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringConstructors
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringIndexOf
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringLengthTrim
This example code is in the public domain.
*/
*/
String txtMsg = ""; // a string for incoming text
unsigned int lastStringLength = txtMsg.length(); // previous length of the String

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringLengthTrim
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringReplace
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringStartsWithEndsWith
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -10,7 +10,7 @@
http://www.arduino.cc/en/Tutorial/StringSubstring
This example code is in the public domain.
*/
*/
void setup() {
// Open serial communications and wait for port to open:

View File

@ -11,7 +11,7 @@
by Tom Igoe
This example code is in the public domain.
*/
*/
String inString = ""; // string to hold input

View File

@ -23,7 +23,7 @@
This example is in the public domain
http://www.arduino.cc/en/Tutorial/KeyboardLogout
*/
*/
#define OSX 0
#define WINDOWS 1

View File

@ -18,7 +18,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/KeyboardMessage
*/
*/
#include "Keyboard.h"

View File

@ -25,7 +25,7 @@
This example is in the public domain
http://www.arduino.cc/en/Tutorial/KeyboardReprogram
*/
*/
#include "Keyboard.h"

View File

@ -17,7 +17,7 @@
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/KeyboardSerial
*/
*/
#include "Keyboard.h"

View File

@ -19,7 +19,7 @@
this code is in the public domain
*/
*/
#include "Keyboard.h"
#include "Mouse.h"

View File

@ -22,7 +22,7 @@
this code is in the public domain
*/
*/
#include "Mouse.h"

View File

@ -26,7 +26,7 @@
this code is in the public domain
*/
*/
#include "Mouse.h"
@ -98,7 +98,7 @@ void loop() {
/*
reads an axis (0 or 1 for x or y) and scales the
analog input range to a range from 0 to <range>
*/
*/
int readAxis(int thisAxis) {
// read the analog input:

View File

@ -16,7 +16,7 @@
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
*/
// named constant for the pin the sensor is connected to
const int sensorPin = A0;

View File

@ -20,7 +20,7 @@
http://www.arduino.cc/starterKit
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
@ -89,7 +89,7 @@ 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);

View File

@ -16,7 +16,7 @@
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
*/
// include the Servo library
#include <Servo.h>

View File

@ -17,7 +17,7 @@
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
*/
// named constant for the switch pin
const int switchPin = 8;

View File

@ -19,7 +19,7 @@
http://www.arduino.cc/starterKit
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

View File

@ -20,7 +20,7 @@
http://www.arduino.cc/starterKit
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

View File

@ -19,7 +19,7 @@
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
*/
// include the library code:
#include <LiquidCrystal.h>

View File

@ -24,7 +24,7 @@
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
*/
// import the library
#include <Servo.h>

View File

@ -21,7 +21,7 @@
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
*/
// import the library (must be located in the
// Arduino/libraries directory)

View File

@ -10,7 +10,7 @@
Software required :
Processing (3.0 or newer) http://processing.org
Active Internet connection
Active Internet connection
Created 18 September 2012
by Scott Fitzgerald
@ -18,7 +18,7 @@
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
*/
void setup() {
@ -99,4 +99,4 @@ void loop() {
// draw the Arduino logo
image(logo, 0, 0);
}
*/
*/

View File

@ -16,7 +16,7 @@
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
*/
const int optoPin = 2; // the pin the optocoupler is connected to

View File

@ -24,7 +24,7 @@
//
// 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
@ -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,10 @@
#endif
// HOODLOADER2 means running sketches on the ATmega16U2
// HOODLOADER2 means running sketches on the ATmega16U2
// serial converter chips on Uno or Mega boards.
// We must use pins that are broken out:
#else
#else
#define RESET 4
#define LED_HB 7
@ -166,51 +166,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);
}
void beginTransaction(SPISettings settings) {
pulseWidth = (500000 + settings.clock - 1) / settings.clock;
if (pulseWidth == 0)
pulseWidth = 1;
}
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);
public:
void begin() {
digitalWrite(PIN_SCK, LOW);
digitalWrite(PIN_MOSI, LOW);
pinMode(PIN_SCK, OUTPUT);
pinMode(PIN_MOSI, OUTPUT);
pinMode(PIN_MISO, INPUT);
}
return b;
}
private:
unsigned long pulseWidth; // in microseconds
void beginTransaction(SPISettings settings) {
pulseWidth = (500000 + settings.clock - 1) / settings.clock;
if (pulseWidth == 0)
pulseWidth = 1;
}
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);
}
return b;
}
private:
unsigned long pulseWidth; // in microseconds
};
static BitBangedSPI SPI;