Skip to content

Use consistent formatting of all code #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@ int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value

void setup()
{
void setup() {
pinMode(ledPin, OUTPUT); // sets the pin as output
}

void loop()
{
void loop() {
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}
Expand Down
6 changes: 2 additions & 4 deletions Language/Functions/Advanced IO/pulseIn.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ The example prints the time duration of a pulse on pin 7.
int pin = 7;
unsigned long duration;

void setup()
{
void setup() {
Serial.begin(9600);
pinMode(pin, INPUT);
}

void loop()
{
void loop() {
duration = pulseIn(pin, HIGH);
Serial.println(duration);
}
Expand Down
18 changes: 8 additions & 10 deletions Language/Functions/Analog IO/analogRead.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,17 @@ The code reads the voltage on analogPin and displays it.

[source,arduino]
----
int analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
int analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read

void setup()
{
Serial.begin(9600); // setup serial
void setup() {
Serial.begin(9600); // setup serial
}

void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
void loop() {
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
----
[%hardbreaks]
Expand Down
12 changes: 5 additions & 7 deletions Language/Functions/Analog IO/analogWrite.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value

void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
void setup() {
pinMode(ledPin, OUTPUT); // sets the pin as output
}

void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
void loop() {
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}
----
[%hardbreaks]
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isAlpha.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isAlpha(thisChar)

[source,arduino]
----
if (isAlpha(myChar)) // tests if myChar is a letter
{
Serial.println("The character is a letter");
if (isAlpha(myChar)) { // tests if myChar is a letter
Serial.println("The character is a letter");
}
else
{
Serial.println("The character is not a letter");
else {
Serial.println("The character is not a letter");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isAlphaNumeric.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isAlphaNumeric(thisChar)

[source,arduino]
----
if (isAlphaNumeric(myChar)) // tests if myChar isa letter or a number
{
Serial.println("The character is alphanumeric");
if (isAlphaNumeric(myChar)) { // tests if myChar isa letter or a number
Serial.println("The character is alphanumeric");
}
else
{
Serial.println("The character is not alphanumeric");
else {
Serial.println("The character is not alphanumeric");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isAscii.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isAscii(thisChar)

[source,arduino]
----
if (isAscii(myChar)) // tests if myChar is an Ascii character
{
Serial.println("The character is Ascii");
if (isAscii(myChar)) { // tests if myChar is an Ascii character
Serial.println("The character is Ascii");
}
else
{
Serial.println("The character is not Ascii");
else {
Serial.println("The character is not Ascii");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isControl.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isControl(thisChar)

[source,arduino]
----
if (isControl(myChar)) // tests if myChar is a control character
{
Serial.println("The character is a control character");
if (isControl(myChar)) { // tests if myChar is a control character
Serial.println("The character is a control character");
}
else
{
Serial.println("The character is not a control character");
else {
Serial.println("The character is not a control character");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isDigit.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isDigit(thisChar)

[source,arduino]
----
if (isDigit(myChar)) // tests if myChar is a digit
{
Serial.println("The character is a number");
if (isDigit(myChar)) { // tests if myChar is a digit
Serial.println("The character is a number");
}
else
{
Serial.println("The character is not a number");
else {
Serial.println("The character is not a number");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isGraph.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isGraph(thisChar)

[source,arduino]
----
if (isGraph(myChar)) // tests if myChar is a printable character but not a blank space.
{
Serial.println("The character is printable");
if (isGraph(myChar)) { // tests if myChar is a printable character but not a blank space.
Serial.println("The character is printable");
}
else
{
Serial.println("The character is not printable");
else {
Serial.println("The character is not printable");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isHexadecimalDigit.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ isHexadecimalDigit(thisChar)

[source,arduino]
----
if (isHexadecimalDigit(myChar)) // tests if myChar is an hexadecimal digit
{
Serial.println("The character is an hexadecimal digit");
if (isHexadecimalDigit(myChar)) { // tests if myChar is an hexadecimal digit
Serial.println("The character is an hexadecimal digit");
}
else
{
Serial.println("The character is not an hexadecimal digit");
else {
Serial.println("The character is not an hexadecimal digit");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isLowerCase.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isLowerCase(thisChar)

[source,arduino]
----
if (isLowerCase(myChar)) // tests if myChar is a lower case letter
{
Serial.println("The character is lower case");
if (isLowerCase(myChar)) { // tests if myChar is a lower case letter
Serial.println("The character is lower case");
}
else
{
Serial.println("The character is not lower case");
else {
Serial.println("The character is not lower case");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isPrintable.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isPrintable(thisChar)

[source,arduino]
----
if (isPrintable(myChar)) // tests if myChar is printable char
{
Serial.println("The character is printable");
if (isPrintable(myChar)) { // tests if myChar is printable char
Serial.println("The character is printable");
}
else
{
Serial.println("The character is not printable");
else {
Serial.println("The character is not printable");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isPunct.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isPunct(thisChar)

[source,arduino]
----
if (isPunct(myChar)) // tests if myChar is a punctuation character
{
Serial.println("The character is a punctuation");
if (isPunct(myChar)) { // tests if myChar is a punctuation character
Serial.println("The character is a punctuation");
}
else
{
Serial.println("The character is not a punctuation");
else {
Serial.println("The character is not a punctuation");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isSpace.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isSpace(thisChar)

[source,arduino]
----
if (isSpace(myChar)) // tests if myChar is the space character
{
Serial.println("The character is a space");
if (isSpace(myChar)) { // tests if myChar is the space character
Serial.println("The character is a space");
}
else
{
Serial.println("The character is not a space");
else {
Serial.println("The character is not a space");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isUpperCase.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ isUpperCase(thisChar)

[source,arduino]
----
if (isUpperCase(myChar)) // tests if myChar is an upper case letter
{
Serial.println("The character is upper case");
if (isUpperCase(myChar)) { // tests if myChar is an upper case letter
Serial.println("The character is upper case");
}
else
{
Serial.println("The character is not upper case");
else {
Serial.println("The character is not upper case");
}

----

--
Expand Down
11 changes: 4 additions & 7 deletions Language/Functions/Characters/isWhitespace.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ isWhitespace(thisChar)

[source,arduino]
----
if (isWhitespace(myChar)) // tests if myChar is a white space
{
Serial.println("The character is a white space");
if (isWhitespace(myChar)) { // tests if myChar is a white space
Serial.println("The character is a white space");
}
else
{
Serial.println("The character is not a white space");
else {
Serial.println("The character is not a white space");
}

----

--
Expand Down
25 changes: 11 additions & 14 deletions Language/Functions/Communication/Serial/available.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,22 @@ The following code returns a character received through the serial port.

[source,arduino]
----
int incomingByte = 0; // for incoming serial data
int incomingByte = 0; // for incoming serial data

void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {

// reply only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();

// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
// reply only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();

// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
----
[%hardbreaks]
Expand All @@ -70,15 +69,13 @@ This code sends data received in one serial port of the Arduino Mega to another.
void setup() {
Serial.begin(9600);
Serial1.begin(9600);

}

void loop() {
// read from port 0, send to port 1:
if (Serial.available()) {
int inByte = Serial.read();
Serial1.print(inByte, DEC);

}
// read from port 1, send to port 0:
if (Serial1.available()) {
Expand Down
Loading