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, June 10, 2014

Trip to Metrix: Making the Photo Resistors Work. Constance Wellman

For our project we used 4 Photo Resistors to count each coin that was dropped into our box, and add the correct amount, by sensing the amount of light that passed through them. In implementing these sensors into our project, we ran into a few problems that we were able to be assisted with at Metrics. At Metrics we learned that although our code was correct, we had placed the Photo Resistors in the breadboard so that the polarization of the pins were incorrect. Below we have posted a photo of how the sensors should be properly placed as well as the correct code to create the count that we desired.


#include <Adafruit_NeoPixel.h>
#define PIN 6
int val1;
int val2;
int val3;
int val4;
int setPoint1 = 100;
int setPoint2 = 100;
int setPoint3 = 100;
int setPoint4 = 100;
//int A = 100;
//int B = 300;
boolean countcheck1 = false;
boolean countcheck2 = false;
boolean countcheck3 = false;
boolean countcheck4 = false;
int count = 0;
int changes = 0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, 2, NEO_GRB + NEO_KHZ800);

void setup()
{
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(A3, INPUT);
  pinMode(A4, INPUT);
  pinMode(A5, INPUT);
  pinMode(A2, INPUT);
  Serial.begin(9600);
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(11, HIGH);
  digitalWrite(10, HIGH);
  
  strip.begin();
  strip.show();
//  stripone.begin();
//  stripone.show();
}

void loop() {
val1 = analogRead(A3);    // Read the analogue input value
//Serial.print("1ai");
//Serial.println(aiValue1);
//Serial.print("slot1count");
//Serial.println(slot1count);

if (val1 < setPoint1 && countcheck1 == false) 
{  count = count + 5;
    Serial.println("count1");
    countcheck1 = true;
  }
  
      
if (val1 > setPoint1)
{ countcheck1 = false;
}

val2 = analogRead(A4);    // Read the analogue input value
//Serial.print("2ai");
//Serial.println(aiValue2);
//Serial.print("slot2count");
//Serial.println(slot2count);

if (val2 < setPoint2 && countcheck2 == false) 
{  count = count + 10;
Serial.println("count2");
    countcheck2 = true; 
  }
  
  
if (val2 > setPoint2)
{ countcheck2 = false;
}   

val3 = analogRead(A5);    // Read the analogue input value
//Serial.print("1ai");
//Serial.println(aiValue1);
//Serial.print("slot1count");
//Serial.println(slot1count);

if (val3 < setPoint3 && countcheck3 == false) 
{  count = count + 25;
    Serial.println("count3");
    countcheck3 = true;
  }
  
if (val3 > setPoint3)
{ countcheck3 = false;
}   

val4 = analogRead(A2);    // Read the analogue input value  

if (val4 < setPoint4 && countcheck4 == false) 
{  count = count + 1;
    Serial.println("count4");
    countcheck4 = true;
  }
  
      
if (val4 > setPoint4)
{ countcheck4 = false;
}






No comments:

Post a Comment