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.
Wednesday, April 24, 2013
Blink and Button //Karin & Enrique
The Button program went fairly well except for the fact that we were missing a resistor. This meant that by closing the circuit the LED went from being on to being brighter. By using the resistor the LED would have been off from the beginning.
This is our blink code (a little too many function calls and too few variables in my opinion.. but it works!):
/*
Blink
Enrique and Karin
*/
// 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() {
//uglyBlink(); //Hardcoded
blinkLoop(); //Looped version
}
void blinkLoop(){ //loops through
int times = 5; //how many blink intervals
int i = 1; //number of blinks
for(i; i<=times; i++){
blinkNormal(i); //calling BlinkNormal function for intervals
delay(600); //delay between intervals
}
delay(2000);
}
void blinkNormal(int times){ //function that blinks the LED a set number of times
for (int i = 1; i<=times; i++){
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(300); // wait
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(300);
}
}
void uglyBlink(){ //hardcoded blinks up to five
blinkNormal(1); //blink once
delay(500);
blinkNormal(1); //blink once
blinkNormal(1); //blink once
delay(500);
blinkNormal(1);
blinkNormal(1);
blinkNormal(1);
delay(500);
blinkNormal(1);
blinkNormal(1);
blinkNormal(1);
blinkNormal(1);
delay(500);
blinkNormal(1);
blinkNormal(1);
blinkNormal(1);
blinkNormal(1);
blinkNormal(1);
delay(500);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment