Week 3 HW – John Boran Jr.

Week three button arduino @bekathwia | @svapod

A post shared by John Boran Jr. (@johnboranjr_pod) on

Week three button reverse @bekathwia | @svapod

A post shared by John Boran Jr. (@johnboranjr_pod) on

Week three resistor removal button @bekathwia | @svapod

A post shared by John Boran Jr. (@johnboranjr_pod) on

Week three digital serial monitor @bekathwia | @svapod

A post shared by John Boran Jr. (@johnboranjr_pod) on

Custom code for arduino – stopping a loop with a button @bekathwia | @svapod

A post shared by John Boran Jr. (@johnboranjr_pod) on

arduino

int timer = 200;  //timer variable created
const int buttonPin = 2; //button is on pin two
int buttonState = 0;  //button state is off, click turns it off normal state
int thisPin = 3;  //start of blinking lights

void setup() {
  for (int thisPin = 3; thisPin < 8; thisPin++) {
    pinMode(thisPin, OUTPUT); //set leds as output
    pinMode(buttonPin, INPUT);  // set button as input
  }
}
void loop() {
  buttonState = digitalRead(buttonPin); //read what the button is doing before loop of leds
  
  if (buttonState == HIGH) {  //if button is not pressed run code
 for (int thisPin = 3; thisPin <  8; thisPin++) {
    // turn the pin on:
    digitalWrite(thisPin, HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(thisPin, LOW);
}
  } else {
    // turn LED off:
    digitalWrite(thisPin, LOW); //if button is pressed do not run code
  }
}