As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Monday, April 29, 2013

5 Blink ~ Nick Stoermer


Five blink sequence

For the brute force it was pretty straight forward groups of on/off separated by delays. For the more effective method I ended up using encapsulation to have a blink function which I could then pass a variable which would define how many time it blinked. I then put this inside a for loop which controlled the variable that was passed. I realized that this project could have been done with  just nested for loops but for the purpose of learning the building blocks of Arduino this was more important. 

code below

~~~~~~~~~~~


/*
  Blink
 Turns on an LED on for one second, then off for one second, repeatedly.

 This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  //1
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  delay(1000)                 // 1 sec pause for inbetween



    //2
    digitalWrite(led, HIGH);   
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  delay(1000)                 // 1 sec pause for inbetween



    //3
    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  delay(1000)                 // 1 sec pause for inbetween




    //4
    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  delay(1000)                 // 1 sec pause for inbetween




    //5

    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(300);  

  delay(1000)                 // 1 sec pause for inbetween




    // wait for a second

  }


No comments:

Post a Comment