Skip to content

Commit 90b33be

Browse files
per1234cmaglie
authored andcommitted
Use consistent line wrapping in built-in example comments
1 parent a2e67e2 commit 90b33be

File tree

60 files changed

+354
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+354
-434
lines changed

examples/01.Basics/Blink/Blink.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
77
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
88
the correct LED pin independent of which board is used.
9-
If you want to know what pin the on-board LED is connected to on your Arduino model, check
10-
the Technical Specs of your board at https://www.arduino.cc/en/Main/Products
9+
If you want to know what pin the on-board LED is connected to on your Arduino
10+
model, check the Technical Specs of your board at:
11+
https://www.arduino.cc/en/Main/Products
1112
1213
modified 8 May 2014
1314
by Scott Fitzgerald

examples/01.Basics/Fade/Fade.ino

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/*
22
Fade
33
4-
This example shows how to fade an LED on pin 9
5-
using the analogWrite() function.
6-
7-
The analogWrite() function uses PWM, so if
8-
you want to change the pin you're using, be
9-
sure to use another PWM capable pin. On most
10-
Arduino, the PWM pins are identified with
11-
a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
4+
This example shows how to fade an LED on pin 9 using the analogWrite()
5+
function.
6+
7+
The analogWrite() function uses PWM, so if you want to change the pin you're
8+
using, be sure to use another PWM capable pin. On most Arduino, the PWM pins
9+
are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
1210
1311
This example code is in the public domain.
1412

examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/*
22
Blink without Delay
33
4-
Turns on and off a light emitting diode (LED) connected to a digital
5-
pin, without using the delay() function. This means that other code
6-
can run at the same time without being interrupted by the LED code.
4+
Turns on and off a light emitting diode (LED) connected to a digital pin,
5+
without using the delay() function. This means that other code can run at the
6+
same time without being interrupted by the LED code.
77
88
The circuit:
99
- Use the onboard LED.
10-
- Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
11-
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
12-
the correct LED pin independent of which board is used.
13-
If you want to know what pin the on-board LED is connected to on your Arduino model, check
14-
the Technical Specs of your board at https://www.arduino.cc/en/Main/Products
10+
- Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
11+
and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
12+
is set to the correct LED pin independent of which board is used.
13+
If you want to know what pin the on-board LED is connected to on your
14+
Arduino model, check the Technical Specs of your board at:
15+
https://www.arduino.cc/en/Main/Products
1516
1617
created 2005
1718
by David A. Mellis
@@ -48,10 +49,9 @@ void setup() {
4849
void loop() {
4950
// here is where you'd put code that needs to be running all the time.
5051

51-
// check to see if it's time to blink the LED; that is, if the
52-
// difference between the current time and last time you blinked
53-
// the LED is bigger than the interval at which you want to
54-
// blink the LED.
52+
// check to see if it's time to blink the LED; that is, if the difference
53+
// between the current time and last time you blinked the LED is bigger than
54+
// the interval at which you want to blink the LED.
5555
unsigned long currentMillis = millis();
5656

5757
if (currentMillis - previousMillis >= interval) {

examples/02.Digital/Button/Button.ino

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
Button
33
4-
Turns on and off a light emitting diode(LED) connected to digital
5-
pin 13, when pressing a pushbutton attached to pin 2.
4+
Turns on and off a light emitting diode(LED) connected to digital pin 13,
5+
when pressing a pushbutton attached to pin 2.
66
77
The circuit:
88
- LED attached from pin 13 to ground
@@ -22,8 +22,7 @@
2222
http://www.arduino.cc/en/Tutorial/Button
2323
*/
2424

25-
// constants won't change. They're used here to
26-
// set pin numbers:
25+
// constants won't change. They're used here to set pin numbers:
2726
const int buttonPin = 2; // the number of the pushbutton pin
2827
const int ledPin = 13; // the number of the LED pin
2928

@@ -41,8 +40,7 @@ void loop() {
4140
// read the state of the pushbutton value:
4241
buttonState = digitalRead(buttonPin);
4342

44-
// check if the pushbutton is pressed.
45-
// if it is, the buttonState is HIGH:
43+
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
4644
if (buttonState == HIGH) {
4745
// turn LED on:
4846
digitalWrite(ledPin, HIGH);

examples/02.Digital/Debounce/Debounce.ino

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
Debounce
33
44
Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
5-
press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's
6-
a minimum delay between toggles to debounce the circuit (i.e. to ignore
7-
noise).
5+
press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's a
6+
minimum delay between toggles to debounce the circuit (i.e. to ignore noise).
87
98
The circuit:
109
- LED attached from pin 13 to ground
1110
- pushbutton attached from pin 2 to +5V
1211
- 10 kilohm resistor attached from pin 2 to ground
1312
14-
- Note: On most Arduino boards, there is already an LED on the board
15-
connected to pin 13, so you don't need any extra components for this example.
13+
- Note: On most Arduino boards, there is already an LED on the board connected
14+
to pin 13, so you don't need any extra components for this example.
1615
1716
created 21 Nov 2006
1817
by David A. Mellis
@@ -28,8 +27,7 @@
2827
http://www.arduino.cc/en/Tutorial/Debounce
2928
*/
3029

31-
// constants won't change. They're used here to
32-
// set pin numbers:
30+
// constants won't change. They're used here to set pin numbers:
3331
const int buttonPin = 2; // the number of the pushbutton pin
3432
const int ledPin = 13; // the number of the LED pin
3533

@@ -38,8 +36,8 @@ int ledState = HIGH; // the current state of the output pin
3836
int buttonState; // the current reading from the input pin
3937
int lastButtonState = LOW; // the previous reading from the input pin
4038

41-
// the following variables are unsigned longs because the time, measured in milliseconds,
42-
// will quickly become a bigger number than can be stored in an int.
39+
// the following variables are unsigned longs because the time, measured in
40+
// milliseconds, will quickly become a bigger number than can be stored in an int.
4341
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
4442
unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
4543

@@ -56,8 +54,8 @@ void loop() {
5654
int reading = digitalRead(buttonPin);
5755

5856
// check to see if you just pressed the button
59-
// (i.e. the input went from LOW to HIGH), and you've waited
60-
// long enough since the last press to ignore any noise:
57+
// (i.e. the input went from LOW to HIGH), and you've waited long enough
58+
// since the last press to ignore any noise:
6159

6260
// If the switch changed, due to noise or pressing:
6361
if (reading != lastButtonState) {
@@ -66,8 +64,8 @@ void loop() {
6664
}
6765

6866
if ((millis() - lastDebounceTime) > debounceDelay) {
69-
// whatever the reading is at, it's been there for longer
70-
// than the debounce delay, so take it as the actual current state:
67+
// whatever the reading is at, it's been there for longer than the debounce
68+
// delay, so take it as the actual current state:
7169

7270
// if the button state has changed:
7371
if (reading != buttonState) {
@@ -83,7 +81,6 @@ void loop() {
8381
// set the LED:
8482
digitalWrite(ledPin, ledState);
8583

86-
// save the reading. Next time through the loop,
87-
// it'll be the lastButtonState:
84+
// save the reading. Next time through the loop, it'll be the lastButtonState:
8885
lastButtonState = reading;
8986
}

examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/*
22
Input Pull-up Serial
33
4-
This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a
5-
digital input on pin 2 and prints the results to the Serial Monitor.
4+
This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a digital
5+
input on pin 2 and prints the results to the Serial Monitor.
66
77
The circuit:
88
- momentary switch attached from pin 2 to ground
99
- built-in LED on pin 13
1010
1111
Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
12-
20K-ohm resistor is pulled to 5V. This configuration causes the input to
13-
read HIGH when the switch is open, and LOW when it is closed.
12+
20K-ohm resistor is pulled to 5V. This configuration causes the input to read
13+
HIGH when the switch is open, and LOW when it is closed.
1414
1515
created 14 Mar 2012
1616
by Scott Fitzgerald
@@ -35,9 +35,8 @@ void loop() {
3535
//print out the value of the pushbutton
3636
Serial.println(sensorVal);
3737

38-
// Keep in mind the pull-up means the pushbutton's
39-
// logic is inverted. It goes HIGH when it's open,
40-
// and LOW when it's pressed. Turn on pin 13 when the
38+
// Keep in mind the pull-up means the pushbutton's logic is inverted. It goes
39+
// HIGH when it's open, and LOW when it's pressed. Turn on pin 13 when the
4140
// button's pressed, and off when it's not:
4241
if (sensorVal == HIGH) {
4342
digitalWrite(13, LOW);

examples/02.Digital/StateChangeDetection/StateChangeDetection.ino

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
State change detection (edge detection)
33
4-
Often, you don't need to know the state of a digital input all the time,
5-
but you just need to know when the input changes from one state to another.
4+
Often, you don't need to know the state of a digital input all the time, but
5+
you just need to know when the input changes from one state to another.
66
For example, you want to know when a button goes from OFF to ON. This is called
77
state change detection, or edge detection.
88
@@ -12,8 +12,8 @@
1212
The circuit:
1313
- pushbutton attached to pin 2 from +5V
1414
- 10 kilohm resistor attached to pin 2 from ground
15-
- LED attached from pin 13 to ground (or use the built-in LED on
16-
most Arduino boards)
15+
- LED attached from pin 13 to ground (or use the built-in LED on most
16+
Arduino boards)
1717
1818
created 27 Sep 2005
1919
modified 30 Aug 2011
@@ -51,29 +51,25 @@ void loop() {
5151
if (buttonState != lastButtonState) {
5252
// if the state has changed, increment the counter
5353
if (buttonState == HIGH) {
54-
// if the current state is HIGH then the button
55-
// went from off to on:
54+
// if the current state is HIGH then the button went from off to on:
5655
buttonPushCounter++;
5756
Serial.println("on");
5857
Serial.print("number of button pushes: ");
5958
Serial.println(buttonPushCounter);
6059
} else {
61-
// if the current state is LOW then the button
62-
// went from on to off:
60+
// if the current state is LOW then the button went from on to off:
6361
Serial.println("off");
6462
}
6563
// Delay a little bit to avoid bouncing
6664
delay(50);
6765
}
68-
// save the current state as the last state,
69-
// for next time through the loop
66+
// save the current state as the last state, for next time through the loop
7067
lastButtonState = buttonState;
7168

7269

73-
// turns on the LED every four button pushes by
74-
// checking the modulo of the button push counter.
75-
// the modulo function gives you the remainder of
76-
// the division of two numbers:
70+
// turns on the LED every four button pushes by checking the modulo of the
71+
// button push counter. the modulo function gives you the remainder of the
72+
// division of two numbers:
7773
if (buttonPushCounter % 4 == 0) {
7874
digitalWrite(ledPin, HIGH);
7975
} else {

examples/02.Digital/toneMelody/toneMelody.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ void setup() {
3131
// iterate over the notes of the melody:
3232
for (int thisNote = 0; thisNote < 8; thisNote++) {
3333

34-
// to calculate the note duration, take one second
35-
// divided by the note type.
34+
// to calculate the note duration, take one second divided by the note type.
3635
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
3736
int noteDuration = 1000 / noteDurations[thisNote];
3837
tone(8, melody[thisNote], noteDuration);

examples/02.Digital/tonePitchFollower/tonePitchFollower.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void loop() {
2929
Serial.println(sensorReading);
3030
// map the analog input range (in this case, 400 - 1000 from the photoresistor)
3131
// to the output pitch range (120 - 1500Hz)
32-
// change the minimum and maximum input numbers below
33-
// depending on the range your sensor's giving:
32+
// change the minimum and maximum input numbers below depending on the range
33+
// your sensor's giving:
3434
int thisPitch = map(sensorReading, 400, 1000, 120, 1500);
3535

3636
// play the pitch:

examples/03.Analog/AnalogInOutSerial/AnalogInOutSerial.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
Analog input, analog output, serial output
33
4-
Reads an analog input pin, maps the result to a range from 0 to 255
5-
and uses the result to set the pulse width modulation (PWM) of an output pin.
4+
Reads an analog input pin, maps the result to a range from 0 to 255 and uses
5+
the result to set the pulse width modulation (PWM) of an output pin.
66
Also prints the results to the Serial Monitor.
77
88
The circuit:
@@ -20,8 +20,7 @@
2020
http://www.arduino.cc/en/Tutorial/AnalogInOutSerial
2121
*/
2222

23-
// These constants won't change. They're used to give names
24-
// to the pins used:
23+
// These constants won't change. They're used to give names to the pins used:
2524
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
2625
const int analogOutPin = 9; // Analog output pin that the LED is attached to
2726

@@ -47,8 +46,7 @@ void loop() {
4746
Serial.print("\t output = ");
4847
Serial.println(outputValue);
4948

50-
// wait 2 milliseconds before the next loop
51-
// for the analog-to-digital converter to settle
52-
// after the last reading:
49+
// wait 2 milliseconds before the next loop for the analog-to-digital
50+
// converter to settle after the last reading:
5351
delay(2);
5452
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy