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.

Tuesday, April 22, 2014

Ichikawa & Lim - Fibonacci

Dominic Challenged the class to make an Arduino blink a light to the Fibonacci sequence. Catherine and I quickly write up a script to make this work. Seems pretty straight forward, and seems to work well.

Excited to see what else this Arduino can do!

Scott & Catherine

/*
  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;
int aNum;
int bNum;
int cNum;


// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT); 
  aNum = 0;  
  bNum = 1;  
  cNum = 0;  
  Serial.begin(9600); 
}

// the loop routine runs over and over again forever:
void loop() {
  cNum = aNum + bNum;
  Serial.println(cNum);
  for(int i = 0; i < cNum; i++){
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(30);               // wait for a second
      digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
      delay(300);   
  }
  //Serial.println(cNum);
  delay(1000);  
  
  aNum = bNum;
  bNum = cNum;
}

No comments:

Post a Comment