Lab 5 - Tea Tester
<Description>
- Input: Opacity of Tea in glass
- Output: Melody corresponding to opacity of each tea
My product concept is to develop a tea tester that measure opacity of each tea back (e.g., Green Tea, Chai Tea, or Coffee) in order to figure out 1)when would be the best to drink, 2) which tea it is. The idea behind is that, users may have unique # code of each tea in a separate chart, and then find out the best moment to drink a tea. Each tea has its own # (resistance) and corresponding melody plays when it's ready to drink. Opacity is a key factor that I use to feature out what that tea is.
<Component>
- Arduino Uno
- Breadboard
- 20, 10 ohm resistors
- Piezo Speaker
- Photo cell
- Green Tea, Chai Tea, Coffee backs
- Containers x 3
<Code>
/*
* Resistive Sensor Input
* Takes the input from a resistive sensor, e.g., photocell
* Dims the LED accordingly, and sends the value (0-255) to the serial port
*/
int sensorPin = A0; // select the input pin for the sensor
int ledPin = 13; // select the output pin for the LED
int val = 0; // variable to store the value coming from the sensor
int val2 = 0;
int speakerOut = 7;
byte names[] = {'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C'};
int tones[] = {1915, 1700, 1519, 1432, 1275, 1136, 1014, 956};
byte melody1[] = "c";
byte melody2[] = "g";
byte melody3[] = "C";
// count length: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
//10 20 30
int count = 0 ;
int count2 = 0;
int MAX_COUNT = 1;
void setup() {
Serial.begin(9600);
pinMode(speakerOut, OUTPUT);
}
void loop() {
digitalWrite(speakerOut, LOW);
val = analogRead(sensorPin); // read the value from the sensor, 0-1023
Serial.println(950-val); // writing the value to the PC via serial connection
val2 = 950 - val;
if(val2 < 110){
digitalWrite(speakerOut, LOW);
}
else if(val2>= 110 && val2 < 200){
for(count = 0; count < MAX_COUNT ; count++)
{
for(count2 = 0; count2 <= 8; count2++)
{
if(names[count2] == melody1[count])
{
digitalWrite(speakerOut,HIGH);
delayMicroseconds(tones[count2]);
digitalWrite(speakerOut,LOW);
delayMicroseconds(tones[count2]);
}
}
}
}
else if (val2 >= 200 && val2 < 320){
for(count = 0; count < MAX_COUNT ; count++)
{
for(count2 = 0; count2 <= 8; count2++)
{
if(names[count2] == melody2[count])
{
digitalWrite(speakerOut,HIGH);
delayMicroseconds(tones[count2]);
digitalWrite(speakerOut,LOW);
delayMicroseconds(tones[count2]);
}
}
}
}
else if (val2 >=320 && val2 < 400){
{
for(count2 = 0; count2 <= 8; count2++)
{
if(names[count2] == melody3[count])
{
digitalWrite(speakerOut,HIGH);
delayMicroseconds(tones[count2]);
digitalWrite(speakerOut,LOW);
delayMicroseconds(tones[count2]);
}
}
}
}
else if (val2 >= 400)
{
digitalWrite(speakerOut, LOW);
}
}
- Login to post comments
Drupal theme by Kiwi Themes.