mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
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:
parent
8f48433f33
commit
eee3e5ba18
@ -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;
|
||||
|
@ -11,7 +11,7 @@
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
This example code is in the public domain
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
//start serial connection
|
||||
|
@ -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
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/Tone3
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "pitches.h"
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/Tone
|
||||
|
||||
*/
|
||||
*/
|
||||
#include "pitches.h"
|
||||
|
||||
// notes in the melody:
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/Tone4
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/Tone2
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
void setup() {
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
int ledPin = 9; // LED connected to digital pin 9
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
<http://www.zambetti.com>
|
||||
|
||||
*/
|
||||
*/
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/Midi
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Set MIDI baud rate:
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
void setup() {
|
||||
|
@ -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:
|
||||
|
@ -18,7 +18,7 @@
|
||||
by Arturo Guadalupi
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
*/
|
||||
|
||||
// pins for the LEDs:
|
||||
const int redPin = 3;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/SerialCallResponse
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
int firstSensor = 0; // first analog sensor
|
||||
int secondSensor = 0; // second analog sensor
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
int firstSensor = 0; // first analog sensor
|
||||
int secondSensor = 0; // second analog sensor
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
@ -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[] = {
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/WhileLoop
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
// These constants won't change:
|
||||
|
@ -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:
|
||||
|
@ -18,7 +18,7 @@
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/SwitchCase2
|
||||
*/
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// initialize serial communication:
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
// these constants won't change:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -18,7 +18,7 @@
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/BarGraph
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
// these constants won't change:
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -10,7 +10,7 @@
|
||||
http://www.arduino.cc/en/Tutorial/StringAppendOperator
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
*/
|
||||
|
||||
String stringOne, stringTwo;
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -10,7 +10,7 @@
|
||||
http://www.arduino.cc/en/Tutorial/StringComparisonOperators
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
*/
|
||||
|
||||
String stringOne, stringTwo;
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -11,7 +11,7 @@
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
*/
|
||||
|
||||
String inString = ""; // string to hold input
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
This example is in the public domain
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardLogout
|
||||
*/
|
||||
*/
|
||||
|
||||
#define OSX 0
|
||||
#define WINDOWS 1
|
||||
|
@ -18,7 +18,7 @@
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardMessage
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "Keyboard.h"
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
This example is in the public domain
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardReprogram
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "Keyboard.h"
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardSerial
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "Keyboard.h"
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
this code is in the public domain
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "Keyboard.h"
|
||||
#include "Mouse.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
this code is in the public domain
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "Mouse.h"
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -24,7 +24,7 @@
|
||||
http://www.arduino.cc/starterKit
|
||||
|
||||
This example code is part of the public domain
|
||||
*/
|
||||
*/
|
||||
|
||||
// import the library
|
||||
#include <Servo.h>
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
@ -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
|
||||
|
||||
|
@ -166,21 +166,21 @@ void pulse(int pin, int times);
|
||||
#define SPI_MODE0 0x00
|
||||
|
||||
class SPISettings {
|
||||
public:
|
||||
public:
|
||||
// clock is in Hz
|
||||
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) : clock(clock){
|
||||
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) : clock(clock) {
|
||||
(void) bitOrder;
|
||||
(void) dataMode;
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
uint32_t clock;
|
||||
|
||||
friend class BitBangedSPI;
|
||||
friend class BitBangedSPI;
|
||||
};
|
||||
|
||||
class BitBangedSPI {
|
||||
public:
|
||||
public:
|
||||
void begin() {
|
||||
digitalWrite(PIN_SCK, LOW);
|
||||
digitalWrite(PIN_MOSI, LOW);
|
||||
@ -209,7 +209,7 @@ public:
|
||||
return b;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
unsigned long pulseWidth; // in microseconds
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user