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.

Sunday, May 12, 2013

Pairing the Photoresistor to the Analog Sensor // karin & kristina's TOOTH MONSTER :)


For the purpose of dispensing floss by utilizing the actuator, this code triggers the actuator to move 180 degrees when the photoresistor is covered. 


#include <Servo.h>    
    Servo myservo;
    int pos = 5;
    int lightPin = 0;
    
    void setup() {
      // attach the pin 9 to the servo
      myservo.attach(9);
      Serial.begin(9600);
    }
    
    void loop() {
      // read the current voltage at lightPin (0) 
      int lightLevel = analogRead(lightPin); 
      Serial.println(lightLevel);
      
      if (lightLevel <= 500) {// turn to 180
      pos = 60;
      myservo.write(pos);
      }
     
      else {//turn to 0
      pos = 0;
      myservo.write(pos);
     }

No comments:

Post a Comment