TristanWENJohn廖宛玲
Published

Water to Friends

A intelligent cup which can measure the temperature of the inside water and hard to incline. Useful to blinds and visually impaired.

BeginnerFull instructions provided6 hours663
Water to Friends

Things used in this project

Hardware components

Arduino Nano V3.0 ATMEGA328P 改進版
$100
×1
LM35 類比溫度感測器
$110
×1
4歐姆 3瓦 喇叭
$60
×1
9V電池扣A(側出線)
$16
×1
Resistor 1k ohm
Resistor 1k ohm
$5
×1
9V battery (generic)
9V battery (generic)
$20
×1
DFPlayer Mini MP3 Player
$145
×1
Micro SD 16GB
$259 (其實有100MB就夠了,但市面上不好找小容量的/ Actually, 100MB is enough to use but it is hard to find the smaller memory SD card)
×1
LM35 類比溫度感測器
$110
×1
Jumper wires (generic)
Jumper wires (generic)
$9 (every 10 of it) 杜邦線材(包括公母) purchased on icShop
×12
Battery Holder, 9V
Battery Holder, 9V
$16 (every 5 of it) 9V電池扣A(側出線) purchased on icShop
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

WTF circuit diagram

Code

WTF Completed code

C/C++
#include "Arduino.h"
#include "SoftwareSerial.h"                    // 採用SoftwareSerial程式庫
#include <DFRobotDFPlayerMini.h>       // 採用DFRobotDFPlayerMini程式庫
//mp3
/*Code designed by Sujay Alaspure in SA Lab */
SoftwareSerial mySoftwareSerial(2, 3);
DFRobotDFPlayerMini myDFPlayer;         //宣告MP3 Player
void printDetail(uint8_t type, int value);  //印出詳情
//sensor
const int sensor=A5; // Assigning analog pin A5 to variable 'sensor'
float tempc; //variable to store temperature in degree Celsius
float tempf; //variable to store temperature in Fahreinheit
float vout; //temporary variable to hold sensor reading
char rT='24';
//toggle
boolean state = false;
void setup() {
//toggle
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
pinMode(7, INPUT);
digitalWrite(7, HIGH);
//MP3 Player
Serial.begin(115200);                 // 定義Serial傳輸速率115200bps
mySoftwareSerial.begin(9600);  // 定義mySoftwareSerial傳輸速率9600bps, DFPlayerMini的通訊速率為9600bps.
myDFPlayer.setTimeOut(500); // 設定通訊逾時為500ms
//----Set volume----
myDFPlayer.volume(30);     // 設定音量, 範圍0~30.
//----Set different EQ----  // 設定EQ(等化器 Equalizer)
myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
//----Set device we use SD as default---- // 設定SD卡
myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
//----Mp3 control---- // 設定MP3參數
myDFPlayer.enableDAC();     //Enable On-chip DAC
pinMode(sensor,INPUT); // Configuring sensor pin as input
Serial.begin(9600);
}

void loop() {
//MP3 player
if (myDFPlayer.available())  // 監視MP3有沒有回應
{                                          // 有的話印出詳情
printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
}
//toggle
if(digitalRead(7) != HIGH){
state = !state;
digitalWrite(13, state);
temp();
delay(2000);}
} //Delay of 1 second for ease of viewing

void temp(){
vout=analogRead(sensor); //Reading the value from sensor
vout=(vout*500)/1023;
if (vout<19.5){
Serial.print("lower than 10");
myDFPlayer.play(4);
}
else if (vout>=19.5 and vout<21){
Serial.print("about 15");
myDFPlayer.play(2);
}
else if (vout>=21 and vout<22){
Serial.print("about 20");
myDFPlayer.play(3);
}
else if (vout>=22 and vout<24){
Serial.print("about 25");
myDFPlayer.play(5);
}
else if (vout>=24 and vout<24.5){
Serial.print("about 30");
myDFPlayer.play(7);
}
else if (vout>=24.5 and vout<26.5){
Serial.print("about 35");
myDFPlayer.play(6);
}
else if (vout>=26.5 and vout<28.5){
Serial.print("about 40");
myDFPlayer.play(10);
}
else if (vout>=28.5 and vout<29.5){
Serial.print("about 45");
myDFPlayer.play(9);
}
else if (vout>=29.5 and vout<31.5){
Serial.print("about 50");
myDFPlayer.play(8);
}
else if (vout>=31.5 and vout<32.5){
Serial.print("about 55");
myDFPlayer.play(11);
}
else{
Serial.print("higher than 60, warnning, its hot.");
myDFPlayer.play(1);
}
Serial.print("in DegreeC=");
Serial.print("\t");
Serial.print(tempc);
Serial.print(" ");
Serial.print("in WTF=");
Serial.print("\t");
Serial.print(rT);
Serial.println();
}

Credits

Tristan

Tristan

1 project • 0 followers
WEN

WEN

1 project • 0 followers
John

John

1 project • 0 followers
廖宛玲

廖宛玲

1 project • 0 followers

Comments