Skip to main content
deleted 52 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

Button Controlling a button

I'm going to write a sketch that would light up the first LED (D1) light of the training shield at the beginning, then will move the LED light to the left or to the right whenever you press the S1 or S2 buttons, respectively. When the LED light is already at the first (D1) or the last (D8), it should no longer move when going further to the left or right, respectively.

Looks exactly like this: https://www.youtube.com/watch?v=_KQQTdDMgOU

Here's what I made so far:

 int x = 0;

 void setup() {
  for(int i=11; i <= 18; i++) { 
    pinMode(i, OUTPUT); 
 } }
 }

 void loop() {
 
  x = digitalRead(pushButtonPin);
 
  if (pushButtonState == HIGH) { 
      // turn LED on: 
      digitalWrite(ledPin, HIGH); 
 } 
 } else {
      // turn LED off:
      digitalWrite(ledPin, LOW); 
  }
}

Button Controlling

I'm going to write a sketch that would light up the first LED (D1) light of the training shield at the beginning, then will move the LED light to the left or to the right whenever you press the S1 or S2 buttons, respectively. When the LED light is already at the first (D1) or the last (D8), it should no longer move when going further to the left or right, respectively.

Looks exactly like this: https://www.youtube.com/watch?v=_KQQTdDMgOU

Here's what I made so far

 int x = 0;

 void setup() {
 for(int i=11; i <= 18; i++) { 
 pinMode(i, OUTPUT); 
 } 
 }

 void loop() {
 
 x = digitalRead(pushButtonPin);
 
 if (pushButtonState == HIGH) { 
      // turn LED on: 
      digitalWrite(ledPin, HIGH); 
 } 
  else {
      // turn LED off:
      digitalWrite(ledPin, LOW); 
 }
}

Controlling a button

I'm going to write a sketch that would light up the first LED (D1) of the training shield at the beginning, then move the LED light to the left or to the right whenever you press the S1 or S2 buttons, respectively. When the LED is already at the first (D1) or the last (D8), it should no longer move when going further to the left or right, respectively.

Looks exactly like this: https://www.youtube.com/watch?v=_KQQTdDMgOU

Here's what I made so far:

int x = 0;

void setup() {
  for(int i=11; i <= 18; i++) {
    pinMode(i, OUTPUT);
  }
}

void loop() {
  x = digitalRead(pushButtonPin);
  if (pushButtonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}
Source Link

Button Controlling

I'm going to write a sketch that would light up the first LED (D1) light of the training shield at the beginning, then will move the LED light to the left or to the right whenever you press the S1 or S2 buttons, respectively. When the LED light is already at the first (D1) or the last (D8), it should no longer move when going further to the left or right, respectively.

Looks exactly like this: https://www.youtube.com/watch?v=_KQQTdDMgOU

Here's what I made so far

 int x = 0;

 void setup() {
 for(int i=11; i <= 18; i++) { 
 pinMode(i, OUTPUT); 
 } 
 }

 void loop() {

 x = digitalRead(pushButtonPin);

 if (pushButtonState == HIGH) { 
      // turn LED on: 
      digitalWrite(ledPin, HIGH); 
 } 
 else {
      // turn LED off:
      digitalWrite(ledPin, LOW); 
 }
}