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.
Showing posts with label Push button. Show all posts
Showing posts with label Push button. Show all posts

Friday, April 25, 2014

Arduino Sensor Experiment | Anjelica Harlow + Albert Lui

Hi there. This is Albert and Angelica, we are now officially a group. I'm leaving for Toronto soon and wont be in class on next week so I figured I would get this out of the way as soon as possible. Pretty simple, I'm using a momentary push button as my 'sensor.'
Whenever the button is pressed down, the red LED lights up. I actually had to build my circuit with a resistor. Our textbook never really tells us why this is necessary and how the circuit actually works. I understand the code completely, but I don't quite understand the electronics. I have a few questions I'm hoping to ask Dominic in person.

Pressing the momentary button down to light up the red LED.

/*
Turns on an LED when the momentary switch is held down.
 */

int led = 13;
int button = 7;
int val = 0;

void setup() {              
  // initialize then digital pins as input/output for the LED an switch
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
}


void loop() {
  val = digitalRead(button);
  if (val == HIGH) { //switch is pressed
    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  } else {
    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  }
}