So the tea sensor works now, and is incredibly useful, as it turns out... i may have to find a way to actually design a real one.
also, Laura and I did the observation exercise in Kimmel, with some interesting (more anthropological than technological) results:
http://itp.nyu.edu/blogs/lc514_pcomp/2009/02/04/observation/
Tuesday, February 3, 2009
Monday, February 2, 2009
here's a problem:
i got the thermisistor to work with one LED, but i was trying to attach a second, and I can't for the life of me get the second to have any brightness whatsoever. I've set it up in an if/else fashion, and wired the two LED's exactly the same way.
here's the way it's set up with a potentiometer instead of a thermisistor (the yellow LED is just hooked to the analog output of the potentiometer):


and here's the code:
int tempPin = 0; //analog input pin from temperature thing = 0
int tempValue = 0; //value read from the temp
int led = 9; //PWM pin that led is on - (PWM 0 = digpin 9)
int clearPin = 2; //pin the clear led is on
int redPin = 3; //pin the red led is on
int THRESHOLD = 860; //threshold of drinkability
void setup() {
pinMode(clearPin, OUTPUT); //clear led pin is an output pin
//initialize serial communication at 9600 bps:
Serial.begin(9600);
}
void loop() {
tempValue = analogRead(tempPin); //read the temperature value
analogWrite(led, tempValue/4); //PWM the led with temp value (divided by 4 to fit in a byte)
Serial.println(tempValue); //print the temp value back to the program
delay(10); //wait 10 ms before looping
if (tempValue <= THRESHOLD) {
digitalWrite(clearPin, HIGH); //turn on clear led
digitalWrite(redPin, LOW); //turn off red led
}
else {
digitalWrite(clearPin, LOW);
digitalWrite(redPin, HIGH);
}
}
any ideas?
i got the thermisistor to work with one LED, but i was trying to attach a second, and I can't for the life of me get the second to have any brightness whatsoever. I've set it up in an if/else fashion, and wired the two LED's exactly the same way.
here's the way it's set up with a potentiometer instead of a thermisistor (the yellow LED is just hooked to the analog output of the potentiometer):


and here's the code:
int tempPin = 0; //analog input pin from temperature thing = 0
int tempValue = 0; //value read from the temp
int led = 9; //PWM pin that led is on - (PWM 0 = digpin 9)
int clearPin = 2; //pin the clear led is on
int redPin = 3; //pin the red led is on
int THRESHOLD = 860; //threshold of drinkability
void setup() {
pinMode(clearPin, OUTPUT); //clear led pin is an output pin
//initialize serial communication at 9600 bps:
Serial.begin(9600);
}
void loop() {
tempValue = analogRead(tempPin); //read the temperature value
analogWrite(led, tempValue/4); //PWM the led with temp value (divided by 4 to fit in a byte)
Serial.println(tempValue); //print the temp value back to the program
delay(10); //wait 10 ms before looping
if (tempValue <= THRESHOLD) {
digitalWrite(clearPin, HIGH); //turn on clear led
digitalWrite(redPin, LOW); //turn off red led
}
else {
digitalWrite(clearPin, LOW);
digitalWrite(redPin, HIGH);
}
}
any ideas?
I'm trying to create a sensor that will determine whether tea is cool enough to drink - it took a while for me to figure out how to deal with the thermisistor, since it (unlike the potentiometer) only has 2 leads... i.e. i had to do some thinking before i figured out that there's no "data" out, and it's just a resistor that changes.
once i figured it out though, i think everything is going well... i've encased the thing in hot glue, so hopefully the values won't get muddled.
once i figured it out though, i think everything is going well... i've encased the thing in hot glue, so hopefully the values won't get muddled.
Subscribe to:
Posts (Atom)