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 24, 2012

Miles & Kim: Arduino Experimentation Round Two

For our second round of experimentation with the Arduino we used Fade and pushButton, and then further manipulated the examples to see what they could do and what the different components of code effected. We began with walking through the previous steps from last post's experiments. We hooked the Arduino Uno up to the computer through the USB port, and uploaded the sketch from each example. This time, it was slightly different, however, because we also needed to use a breadboard, switch, and a resistor. Each exercise required the LED or the switch to be placed on the breadboard, with two wires connecting into the correct pints on the Arduino.

Here is our completion of pushButton:






































Here is our completion of Fade:



When we completed each of these examples we played with the code to see what else we could do. We began with altering the delay in Fade. We changed it first to 80, prolonging the "fade" effect, and then to 10, causing the flashing to occur at a faster rate. We then considered combining the original Blinking LED exercise with Fade, so we put code into the loop that would make the LED flash while simultaneously fading. Here is the code to achieve that:


/*
 Fade

 This example shows how to fade an LED on pin 9
 using the analogWrite() function.

 This example code is in the public domain.

 */
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup()  {
  // declare pin 9 to be an output:
  pinMode(9, OUTPUT);
}

void loop()  {
 
  // set the brightness of pin 9:
  analogWrite(9, brightness);  

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }    
  // wait for 30 milliseconds to see the dimming effect  

  delay(30);
  digitalWrite(9, HIGH);   // set the LED on
  delay(500);              // wait for a second
  digitalWrite(9, LOW);    // set the LED off
  delay(500);              // wait for a second

}

Unfortunately, the flashing appears to overpower the fade. We think this is because it runs through the fade loop so quickly that it goes unnoticed and without feedback from the device.

We then commented out the new flashing code, and decided to mess with the brightness to see what effect it had. We realized that changing the "255" did not make it brighter or less bright directly, but instead stopped the flashing earlier, changing the rhythm of the fade.

No comments:

Post a Comment