
Greetings. This is the temporary home for my Physical Computing blog (my real blog is broken right now)...
For our first project in Physical Computing, we were asked to create a simple device that controls an LED based on an analog input.
After toying around with different variable resistors, I decided to make a device that can test the temperature of a beverage and give you a rating based on your personal preference.
The "Tongue Saver" requires that you first adjust it to your desired temperature by sensing a beverage that you are already comfortable with. Once you have calibrated the device, you can then test the next beverage, and it will show you, based on the LEDs, whether or not it is to your standards. The center LED indicated that your drink is just right. The LEDs left of the sensor indicate the beverage is too cold, and on the right they indicate it's too hot. If no LEDs light up, it's way off!
Here is the arduino code:
// Tongue Saver ver 1.0
// by Jared Domonell
int thermSensor = 0;
int potSensor = 1;
int lightOne = 3;
int lightTwo = 4;
int lightThree = 5;
int lightFour = 6;
int lightFive = 7;
int thermValue = 0;
int potValue = 0;
void setup()
{
Serial.begin(9600);
pinMode(lightOne, OUTPUT);
pinMode(lightTwo, OUTPUT);
pinMode(lightThree, OUTPUT);
pinMode(lightFour, OUTPUT);
pinMode(lightFive, OUTPUT);
}
void loop()
{
thermValue = analogRead(thermSensor);
potValue = analogRead(potSensor);
float fT = float(thermValue);
float fP = float(potValue);
float diff = (fP - fT);
int val = round(map(diff,-1024,1024,-100,100));
Serial.println("mapped value ");
Serial.println(val);
if(val > - 2 && val <> 2 && val <> 6 && val <> -6 && val < -2) { digitalWrite(lightOne, LOW); digitalWrite(lightTwo, HIGH); digitalWrite(lightThree, LOW); digitalWrite(lightFour, LOW); digitalWrite(lightFive, LOW); } else if (val > -12 && val < -6) { digitalWrite(lightOne, HIGH); digitalWrite(lightTwo, LOW); digitalWrite(lightThree, LOW); digitalWrite(lightFour, LOW); digitalWrite(lightFive, LOW); } else if( val <= -12 || val >= 12)
{
digitalWrite(lightOne, LOW);
digitalWrite(lightTwo, LOW);
digitalWrite(lightThree, LOW);
digitalWrite(lightFour, LOW);
digitalWrite(lightFive, LOW);
}
}
The thermistor sensor:

A closer image:
No comments:
Post a Comment