Tuesday, February 28, 2017

Interesting Push Button
   My "Interesting Push Button" causes the LEDs to light up from one end to the other. As the electricity conducts through the scissors, wire cutter, and screw driver, the lights start at LED 13 and goes to LED 9. Then they start at LED 9 again and back to LED 13. Only one light is lit at one time. Once the wire is lifted off of the screw driver, the sequence stops. It starts all over again once the wire is placed back on the screw driver. Every time the LED 13 lights up, the light on the RedBoard, 13, will light up.

CODE
int ledpin = 9;
int buttonPin = 2;
int buttonState = 0;
void setup() {
  Serial.begin(9600);
  pinMode(buttonPin, INPUT);

}

void loop() {
  delay(100);
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH)
  {
    Serial.println("Button Pressed");
    while (ledpin >=9)
    {
      pinMode (ledpin, OUTPUT);
      digitalWrite(ledpin, HIGH);
      delay(100);
      digitalWrite(ledpin, LOW);
      ledpin=ledpin-1;
    }
  {
    Serial.println("Waiting");
    while (ledpin <= 13)
    {
     pinMode (ledpin, OUTPUT);
     digitalWrite(ledpin, HIGH);
     delay(100);
      digitalWrite(ledpin, LOW);
      ledpin=ledpin+1;
    }
  }
  ledpin = 9;
  ledpin = 13;
  }
}

URL to Video
https://www.youtube.com/watch?v=3bdYIU7NU1o&feature=youtu.be

No comments:

Post a Comment