Skip to content

Simplify some examples #3997

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

Closed
wants to merge 1 commit into from
Closed
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 @@ -54,11 +54,7 @@ void loop() {
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
ledState ^= HIGH;

// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
Expand Down
19 changes: 3 additions & 16 deletions build/shared/examples/02.Digital/Button/Button.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
Expand All @@ -40,16 +37,6 @@ void setup() {
}

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:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
// If the button is pressed, light up the LED:
digitalWrite(ledPin, digitalRead(buttonPin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ void loop() {
// 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);
} else {
digitalWrite(13, HIGH);
}
digitalWrite(13, !sensorVal);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ void loop() {
// 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 {
digitalWrite(ledPin, LOW);
}

digitalWrite(ledPin, buttonPushCounter % 4 == 0);
}


Expand Down