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.

Friday, June 12, 2020

Voltage Divider Experimentation

For this project, while setting up the circuit I ran into an issue of my LED not lighting up. After double checking the resistors and removing the LDR to learn that the LED was lighting up properly, (like Lily) I learned that the code itself needed to be changed to reflect my lighting situation. I also thought the value of the LDR being 25 seemed really low after realizing this.




After that was fixed, I changed the code so that the LED would blink in a loop unless the value of the LDR was less than 400, in which case it would turn off. Through this experimentation is how I was inspired to create an alarm that alerts me when my cat is on the counter.



//Constants
const int pResistor = A0; // Photoresistor at Arduino analog pin A0
const int ledPin=9;       // Led pin at Arduino pin 9

//Variables
int value;          // Store value from photoresistor (0-1023)

void setup(){
 pinMode(ledPin, OUTPUT);  // Set lepPin - 9 pin as an output
 pinMode(pResistor, INPUT);// Set pResistor - A0 pin as an input (optional)
}

void loop(){
  value = analogRead(pResistor);
 
  if (value >= 400){
    digitalWrite(ledPin, LOW);
    delay(100);
    digitalWrite(ledPin, HIGH);
    delay(100);
   
  }
  else{
    digitalWrite(ledPin, LOW); //Turn led off
  }

}

No comments:

Post a Comment