Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 2 | ||||
| × | 2 | ||||
Software apps and online services | ||||||
| ||||||
| ||||||
| ||||||
| ||||||
Hand tools and fabrication machines | ||||||
| ||||||
| ||||||
| ||||||
|
The Problem
Have you ever left your windows open on a hot summer day?
Sure, this helps a lot, but weather can be very unpredictable.
What if it starts raining?
Either, you have to stop whatever you’re doing and manually roll the windows up OR you leave your windows open and suffer rain damage in the interior.
If rain damage is left untreated, it leads to mold in your car and could cause significant health risks. Uh Oh... The Solution: TiWo
The Solution: TiWo
TiWo automatically controls and adjusts your windows based on the temperature and rain to keep your car comfortable and protected.
TiWo has 3 Main Features:
1.Temperature Sensor- Measures the temperature inside and outside your vehicle and adjust the windows accordingly
2. Rain or Moisture Sensor- Senses rain and automatically rolls up your windows in order to keep the interior dry.
3.App- Allows YOU to receive information and adjust your windows from anywhere
Here is some simple math:
If Summer = hot weather
Hot weather + car = hot car = 3rd degree burns
Therefore hot car = unhappy person
But,
Windows open + hot car = cooler car < hot car
If E rain such that rain + cooler car = wet car = MOLD,
Then windows closed + wet car = dry car
Therefore,
Dry car || (cooler car && ! rain) = happy person
TiWo App
Javapackage com.jessica.windows;
import android.os.Bundle;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
public class MainActivity extends Activity
{
ToggleButton toggleButton;
TextView windowView0, tempView0, tempView1, rain;
Handler bluetoothIn;
final int handlerState = 0; //used to identify handler message
private BluetoothAdapter btAdapter = null;
private BluetoothSocket btSocket = null;
private StringBuilder recDataString = new StringBuilder();
private ConnectedThread mConnectedThread;
// SPP UUID service - this should work for most devices
private static final UUID BTMODULEUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
// String for MAC address
private static String address;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Link the buttons and textViews to respective views
toggleButton = (ToggleButton) findViewById(R.id.toggleButton);
windowView0 = (TextView) findViewById(R.id.windowView0);
tempView0 = (TextView) findViewById(R.id.tempView0);
tempView1 = (TextView) findViewById(R.id.tempView1);
rain = (TextView) findViewById(R.id.rain);
bluetoothIn = new Handler()
{
public void handleMessage(android.os.Message msg)
{
if (msg.what == handlerState) //if message is what we want
{
String readMessage = (String) msg.obj; // msg.arg1 = bytes from connect thread
recDataString.append(readMessage); //keep appending to string until ~
int endOfLineIndex = recDataString.indexOf("~"); // determine the end-of-line
if (endOfLineIndex > 0)
{ // make sure there is data before ~
String dataInPrint = recDataString.substring(3, endOfLineIndex); //extract string that is received
int dataLength = dataInPrint.length(); //get length of data received
//cases depending on what is sent through Bluetooth
if (recDataString.charAt(2) == 'i') //receive 'i' for inside temperature, format: i##
{
tempView0.setText("Inside Temperature = " + dataInPrint + "C");
}
else if (recDataString.charAt(2) == 'o') //receive 'o' for outside temperature, format: o##
{
tempView1.setText("Outside Temperature = " + dataInPrint + "C");
}
else if (recDataString.charAt(2) == 'x') //receive 'x' when window is closed
{
windowView0.setText("Window is closed.");
Toast.makeText(getBaseContext(), "Windows rolled up.",Toast.LENGTH_SHORT).show();
}
else if (recDataString.charAt(2) == 'h') { // receive 'h' when window is opened
windowView0.setText(" Window is open.");
Toast.makeText(getBaseContext(), "Windows rolled down.",Toast.LENGTH_SHORT).show();
}
else if (recDataString.charAt(2) == 'w') //receive 'w' when it is raining
{
rain.setText("It is raining.");
toggleButton.setChecked(false);
windowView0.setText("Window is closed.");
Toast.makeText(getBaseContext(), "Windows rolled up.",Toast.LENGTH_SHORT).show();
}
else if (recDataString.charAt(2) == 'd') //receive 'd' when it is not raining
{
rain.setText("It is not raining.");
}
else if (recDataString.charAt(2) == 'b') //receive 'b' when outside temp is greater than inside
{
Toast.makeText(getBaseContext(), "It's getting hot!", Toast.LENGTH_SHORT).show();
}
else if (recDataString.charAt(2) == 'c') //receive 'c' when inside temp is less than outside
{
Toast.makeText(getBaseContext(), "It's cooling down!", Toast.LENGTH_SHORT).show();
}
//otherwise do nothing
recDataString.delete(0, recDataString.length()); //clear all string data
}
}
}
};
btAdapter = BluetoothAdapter.getDefaultAdapter(); // get Bluetooth adapter
checkBTState();
}
public void toggleWindows(View view)
{
boolean on = ((ToggleButton) view).isChecked();
if (on)
{
mConnectedThread.write("1"); //send "1" via Bluetooth to roll down windows
}
else
{
mConnectedThread.write("0"); //send "0" via Bluetooth to open windows
}
}
private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException
{
return device.createRfcommSocketToServiceRecord(BTMODULEUUID); //creates secure outgoing connecetion with BT device using UUID
}
@Override
public void onResume()
{
super.onResume();
address = "20:15:05:20:18:01"; //MAC address for Bluetooth module
//create device and set the MAC address
BluetoothDevice device = btAdapter.getRemoteDevice(address);
try
{
btSocket = createBluetoothSocket(device);
} catch (IOException e) {
Toast.makeText(getBaseContext(), "Socket creation failed", Toast.LENGTH_LONG).show();
}
// Establish the Bluetooth socket connection.
try
{
btSocket.connect();
} catch (IOException e)
{
try
{
btSocket.close();
} catch (IOException e2)
{
//insert code to deal with this
}
}
mConnectedThread = new ConnectedThread(btSocket);
mConnectedThread.start();
//I send a character when resuming.beginning transmission to check device is connected
//If it is not an exception will be thrown in the write method and finish() will be called
mConnectedThread.write("x");
}
@Override
public void onPause()
{
super.onPause();
try
{
//Don't leave Bluetooth sockets open when leaving activity
btSocket.close();
} catch (IOException e2) {
//insert code to deal with this
}
}
//Checks that the Android device Bluetooth is available and prompts to be turned on if off
private void checkBTState() {
if(btAdapter==null) {
Toast.makeText(getBaseContext(), "Device does not support bluetooth", Toast.LENGTH_LONG).show();
} else {
if (btAdapter.isEnabled())
{int x=0;
x++;
}
else {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
}
}
//create new class for connect thread
private class ConnectedThread extends Thread {
private final InputStream mmInStream;
private final OutputStream mmOutStream;
//creation of the connect thread
public ConnectedThread(BluetoothSocket socket) {
InputStream tmpIn = null;
OutputStream tmpOut = null;
try {
//Create I/O streams for connection
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) { }
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
public void run() {
byte[] buffer = new byte[256];
int bytes;
// Keep looping to listen for received messages
while (true) {
try {
bytes = mmInStream.read(buffer); //read bytes from input buffer
String readMessage = new String(buffer, 0, bytes);
// Send the obtained bytes to the UI Activity via handler
bluetoothIn.obtainMessage(handlerState, bytes, -1, readMessage).sendToTarget();
} catch (IOException e) {
break;
}
}
}
//write method
public void write(String input) {
byte[] msgBuffer = input.getBytes(); //converts entered String into bytes
try {
mmOutStream.write(msgBuffer); //write bytes over BT connection via outstream
} catch (IOException e) {
//if you cannot write, close the application
Toast.makeText(getBaseContext(), "Connection Failure", Toast.LENGTH_LONG).show();
finish();
}
}
}
}
TiWo Energia
C/C++#include <TM1637.h>
#include <DHT.h>
#include <TM1638.h>
#include <DHT1.h>
/***************************************************************************************
*
*
* Salvador Baca
* Bluetooth HC-05 Communication
* TM1637 7 Segment LED
* DHT Temperature Sensor
* Water Sensor
* 07/09/2015
*
* ______________________
* | |
* Bluetooth -----> |P3.2 RX |
* Bluetooth <----- |P3.3 TX |
* Water -----> |P6.1 |
* Display <----- |P4.0 P2.5|<------ Relay WindowDown
* Display <----- |P4.2 P3.0|------->Relay WindowUp
* Temperaturei -----> |6.5 P2.4|------>Display
* Temperatureo -----> |6.4 P5.6|------>Display
* | |
* ---------------------|
*
*
*
***********************************************************************************/
/**********************************************************************************************************
*
* The program performs the following tasks:
* If the program receives a "1" it will turn on Green LED and send temperature inside and outside information
* It the program receives a "0" it will turn off Green LED
* If the program temperaure inside car(t_bits[]) higher than temperature outside(tt_bits[]); it will open window
* If the program temperaure inside car(t_bits[]) lower than temperature outside(tt_bits[]); it will close window
*
***************************************************************************************************************/
//MACRO Define Sensors 1
#define CLK 25 //4-digital display clock pin yellow
#define DIO 24 //4-digital display data pin white
#define Water 6 //Water Sensor Pin
#define BLINK_LED RED_LED //Blink LED
#define TEMP_HUMI_PIN 9 //Pin of temperature&humidity sensor
//MACRO Define Sensors 2
#define CLK1 37 //4-digital display clock pinP5.6
#define DIO1 38 //4-digital display data pin
#define BLINK_LED 2 //Blink LED
#define TEMP_PIN 10 //Pin of temperature&humidity sensor
//Macro Define for Relays
#define WindowUp 18
#define WindowDown 19
/*Global Variables Sensor 1*/
TM1637 TM1637(CLK, DIO); //4-digital display object
DHT DHT(TEMP_HUMI_PIN, DHT22); //Temperature&humidity sensor object
int8_t t_bits[2] = {0}; //Array to store the single bits of the temperature
int8_t h_bits[2] = {0}; //Array to store the single bits of the humidity
/*Global Variables Sensor 2*/
TM1638 TM1638(CLK1, DIO1); //4-digital display object
DHTT DHTT(TEMP_PIN, DHT22); //Temperature&humidity sensor object
int8_t tt_bits[2] = {0}; //Array to store the single bits of the temperature
int8_t hh_bits[2] = {0}; //Array to store the single bits of the humidity
/*Initialize Strings that will be sent to app*/
String temp = ""; //Initialize String
String temp1 = ""; //Initialize String
String tempi = ""; //Initialize string temperature inside
String tempo = ""; //Initialize string temperature outside
//Flags to keep track of actions
int state = 0; //Store value received trough bluetooth
int flag = 0; //Flag that indicates that feedback has been sent to terminal
int temp_hot =1; //Flag to let us know that HOT signal was already sent
int temp_sent =0; //Flag to let us know that Temp signal was already sent when opening window
int temp_sent2 =0; //Flag to let us know that Temp signal was already sent when closing window
int WaterState =0; //Flag to let us know if it is raining
int Water_flag =0; //Flag to let us know that Water signal was already sent
int WindowStatus =1; //Allows me to keep track of where window is
void setup()
{
/*Setup for temperature Sensor 1*/
TM1637.init(); //Initialize 4-digital display
TM1637.set(BRIGHT_TYPICAL); //Temperature&humidity sensor object
TM1637.point(POINT_ON); //Light the Clock point ":"
DHT.begin(); //Initialize temperature and humidity sensor
pinMode(RED_LED, OUTPUT); //Declare the red_led pin as an OUTPUT
/*Setup for temperature Sensor 2*/
TM1638.init(); //Initialize 4-digital display
TM1638.set(BRIGHT_TYPICAL); //Temperature&humidity sensor object
TM1638.point(POINT_ON); //Light the Clock point ":"
DHTT.begin(); //Initialize temperature and humidity sensor
pinMode(BLINK_LED, OUTPUT); //Declare the red_led pin as an OUTPUT
/*Initialize Pinmodes*/
pinMode(GREEN_LED, OUTPUT); //Set Green LED as an output
digitalWrite(GREEN_LED, LOW); //Turn off Green LED
pinMode(Water, INPUT); //Pin 6 as an input
pinMode(WindowUp, OUTPUT); //Set Window as an output
pinMode(WindowDown, OUTPUT); //Set Window pin as an output
Serial1.begin(9600); //Set baud rate at 9600
}
void loop()
{
/*Set up for temperature Sensor 1*/
int _temperature= DHT.readTemperature(); //Read the temperature value from temperature sensor
int _humidity = DHT.readHumidity(); //Read the humidity value from humidity sensor
memset(t_bits, 0, 2); //Reset Array once used
memset(h_bits, 0, 2);
t_bits[0] = _temperature % 10; //4-digital-display [0,1] is used to display temperature
_temperature /= 10;
t_bits[1] = _temperature % 10; //4-digital-display [2,3] is used to display temperature
h_bits[0] = _humidity % 10;
_humidity /= 10;
h_bits[1] = _humidity % 10;
/*Set up for temperature Sensor 2 */
int _temperature1= DHTT.readTemperature(); //Read the temperature value from temperature sensor
int _humidity1 = DHTT.readHumidity(); //Read the humidity value from humidity sensor
memset(tt_bits, 0, 2); //Reset Array once used
memset(hh_bits, 0, 2);
tt_bits[0] = _temperature1 % 10; //4-digital-display [0,1] is used to display temperature
_temperature1 /= 10;
tt_bits[1] = _temperature1 % 10; //4-digital-display [2,3] is used to display temperature
hh_bits[0] = _humidity1 % 10;
_humidity1 /= 10;
hh_bits[1] = _humidity1 % 10;
WaterState = digitalRead(Water); //Read Pin 6 to check temperature sensor
temp = String(t_bits[1]) + String(t_bits[0]) + "~"; //Concatenate into a single string to be sent to the app
temp1 = String(tt_bits[1]) + String(tt_bits[0]) + "~"; //Concatenate into a single string to be sent to the app
if(Serial1.available() > 0)
{
state = Serial1.read(); //store value received to state to later compare.
flag = 0;
}
if(state == '0') /***When we want to close the window***/
{
digitalWrite(GREEN_LED, LOW); //Turn off green LED
if((temp_sent2 == 0)&&(WaterState == 1))
{
Serial1.println(""); //Output on terminal
Serial1.print("x~"); //Output on terminal
delay(500); //Delay .5 Sec
Serial1.println(""); //Output on terminal
tempi = String( "i" + temp);
Serial1.print(tempi); // Display temperature inside on app
delay(500); //Delay .5 Sec
Serial1.println(""); //Output on terminal
tempo = String( "o" + temp1);//Temperature outside Sensor two
Serial1.print(tempo); // Display temperature inside on app
delay(500); //Delay .5 Sec
if(WindowStatus == 2)//When window is fully open
{
/***********************Fully Close*************************************/
/***********************Use 3.1 Sec Delay*******************************/
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, LOW); //Turn on green LED
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(100); //Delay 1 Sec
digitalWrite(WindowUp, HIGH); //Turn on green LED
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
WindowStatus = 1;
/************************************************************************/
}
else if(WindowStatus == 3)//When Window is Partially Open
{
/**********Partially Close*************************************************/
/********************** Use .38 Delay***************************************/
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, LOW); //Turn on green LED
delay(380); //Delay 1 Sec
digitalWrite(WindowUp, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
WindowStatus = 1;
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
}
temp_sent2 =1; //Set Flag to let MSP know that temperature and signal was sent
}
temp_sent = 0; //Re-initilialize flag for window up
if(flag == 0)
{
flag =1;
}
}
else if(state =='1')/***Window Open***/
{
digitalWrite(GREEN_LED, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
digitalWrite(GREEN_LED, LOW); //Turn off green LED
if((temp_sent == 0)&&(WaterState == 1))
{
Serial1.println(""); //Output on terminal
Serial1.print("h~"); //Output on terminal
delay(500); //Delay .5 Sec
Serial1.println(""); //Output on terminal
tempi = String( "i" + temp); //Concatenate i +temp bits + ~
Serial1.print(tempi); // Display temperature inside on app
delay(500); //Delay .5 Sec
Serial1.println(""); //Output on terminal
tempo = String( "o" + temp1); //Temperature outside Sensor two
Serial1.print(tempo); // Display temperature inside on app
if(WindowStatus == 1)//When Window is fully Closed
{
/********************** Fully Close***************************************/
/********************** Use 2.360 Delay***************************************/
digitalWrite(WindowUp, HIGH); //Turn on green LED
digitalWrite(WindowDown, LOW); //Turn on green LED
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(360); //Delay 1 Sec
digitalWrite(WindowDown, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
WindowStatus = 2;
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
}
else if(WindowStatus ==3)
{
/********************** Open from partially open*****************************/
/********************** Use 2.120Delay***************************************/
digitalWrite(WindowUp, HIGH); //Make Sure Relay 2 is off
digitalWrite(WindowDown, LOW); //Roll window Down
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(120); //Delay 1 Sec
digitalWrite(WindowDown, HIGH); //Stop Rolling Window Down
delay(1000); //Delay 1 Sec
WindowStatus = 2;
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
}
temp_sent =1; //Set Flag to let MSP know that temperature and signal was sent
}
temp_sent2 = 0; //Re-initilialize flag for window down
if(flag == 0)
{
flag =1;
}
}
/************************** *Code to monitor rain Sensor* *******************/
/*****************************************************************************************************************/
if((WaterState == 0) && (Water_flag == 0)) /***Check when water is sensed***/
{
//Serial1.println("Water!!!"); //Output on terminal
Serial1.println(""); //Output on terminal
Serial1.print("w~"); //Output on terminal
delay(500); //Delay .5 Sec
if(WindowStatus == 2)//When window is fully open
{
/***********************Fully Close*************************************/
/***********************Use 3.1 Sec Delay*******************************/
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, LOW); //Turn on green LED
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(100); //Delay 1 Sec
digitalWrite(WindowUp, HIGH); //Turn on green LED
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
WindowStatus = 1;
/************************************************************************/
}
else if(WindowStatus == 3)//When Window is Partially Open
{
/**********Partially Close*************************************************/
/********************** Use .38 Delay***************************************/
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, LOW); //Turn on green LED
delay(380); //Delay 1 Sec
digitalWrite(WindowUp, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
WindowStatus = 1;
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
}
temp_sent2 =0; //Set Flag to let MSP know that temperature and signal was sent
Water_flag = 1; //Water Flag to prevent sending too many signals
}
if((WaterState == 1) && (Water_flag == 1)) /***Check when it stops raining***/
{
Serial1.println(""); //Output on terminal
Serial1.print("d~"); //Output on terminal
delay(500); //Delay .5 Sec
Water_flag = 0; //Reset water Flag to prevent sending too many signals
}
/*****************************************************************************************************************/
/************************** *Code to monitor temperature inside and outside car* *******************/
/*****************************************************************************************************************/
if((t_bits[1] > tt_bits[1]) &&(temp_hot ==0)&&(WaterState == 1)) /*** Temperature inside the car is hotter than outside temperature**/
{
//Serial1.println("HOT!!!"); //Output on terminal
Serial1.println(""); //Output on terminal
Serial1.print("b~"); //Output on terminal
delay(500); //Delay .5 Sec
Serial1.println(""); //Output on terminal
tempi = String( "i" + temp);
Serial1.print(tempi); // Display temperature inside on app
delay(500); //Delay .5 Sec
Serial1.println(""); //Output on terminal
tempo = String( "o" + temp1);//Temperature outside Sensor two
Serial1.print(tempo); // Display temperature inside on app
if(WindowStatus == 1)//When Window is fully closed
{
/********************** Use .3 Delay***************************************/
digitalWrite(WindowUp, HIGH); //Turn on green LED
digitalWrite(WindowDown, LOW); //Turn on green LED
delay(300); //Delay 1 Sec
digitalWrite(WindowDown, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
}
if(WindowStatus == 2)//If Window is fully
{
/***********************Fully Close*************************************/
/***********************Use 3.1 Sec Delay*************************************/
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, LOW); //Turn on green LED
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(100); //Delay 1 Sec
digitalWrite(WindowUp, HIGH); //Turn on green LED
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
/************************Partially Open*************************************/
/********************** Use .3 Delay***************************************/
digitalWrite(WindowUp, HIGH); //Turn on green LED
digitalWrite(WindowDown, LOW); //Turn on green LED
delay(300); //Delay 1 Sec
digitalWrite(WindowDown, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
}
WindowStatus = 3;
temp_hot =1; //Temperature Signal was sent
}
if((t_bits[1] <= tt_bits[1])&&(temp_hot ==1)&&(WaterState == 1)) /***Temperature inside the car is cooler than outside car***/
{
//Serial1.println("NICE!!!"); //Output on terminal
Serial1.println(""); //Output on terminal
Serial1.print("c~"); //Output on terminal
delay(500); //Delay .5 Sec
Serial1.println(""); //Output on terminal
tempi = String( "i" + temp);
Serial1.print(tempi); // Display temperature inside on app
delay(500); //Delay .5 Sec
Serial1.println(""); //Output on terminal
tempo = String( "o" + temp1);//Temperature outside Sensor two
Serial1.print(tempo); // Display temperature outside on app
temp_hot =0; //Temperature signal
if(WindowStatus == 2)//If Window is fully Open
{
/***************************Fully Close***************************************/
/************************Use 3.1 Sec Delay************************************/
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, LOW); //Turn on green LED
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(1000); //Delay 1 Sec
delay(100); //Delay 1 Sec
digitalWrite(WindowUp, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
}
if(WindowStatus == 3)// If Window is partially open
{
/***************************Partially Close**********************************/
/***************************Use .38 Delay************************************/
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, LOW); //Turn on green LED
delay(380); //Delay 1 Sec
digitalWrite(WindowUp, HIGH); //Turn on green LED
delay(1000); //Delay 1 Sec
digitalWrite(WindowDown, HIGH); //Turn on green LED
digitalWrite(WindowUp, HIGH); //Turn on green LED
/************************************************************************/
}
WindowStatus = 1;
}
/*****************************************************************************************************************/
/* show it 7-Segment Display*/
TM1637.display(1, t_bits[0]);
TM1637.display(0, t_bits[1]);
TM1637.display(3, h_bits[0]);
TM1637.display(2, h_bits[1]);
/* show it Display on 2nd 7-Segment Display*/
TM1638.display(1, tt_bits[0]);
TM1638.display(0, tt_bits[1]);
TM1638.display(3, hh_bits[0]);
TM1638.display(2, hh_bits[1]);
}
Comments