Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String menuItems[] = {"Welcome!","Display Stats","Set Samsung", "Set Daewoo", "Add remote","Set Humidity(beta)",""};
- String subMenu[]={"17 C","18 C","19 C","20 C","21 C","22 C","23 C","24 C","25 C","Back",""};
- String subMenu1[]={"17 C","18 C","19 C","20 C","21 C","22 C","23 C","24 C","25 C","Back",""};
- String subMenuH[]={"30-40 %","40-50 %","35-45 %","<60%"};
- #define maxLen 800
- #define rxPinIR 2
- const int chipSelect = 53;
- volatile unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR
- volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR
- void rxIR_Interrupt_Handler() {
- if (x > maxLen) return; //ignore if irBuffer is already full
- irBuffer[x++] = micros(); //just continually record the time-stamp of signal transitions
- }
- int readKey;
- int savedDistance = 0;
- // Menu control variables
- int menuPage = 0;
- int maxMenuPages = 0;
- int cursorPosition = 0;
- int maxCursorPosition=0;
- int subPage=0;
- int maxSubPages = 0;
- int subCursor=0;
- int maxCursorPositionS=0;
- int subPageD=0;
- int maxSubPagesD = 0;
- int subCursorD=0;
- int maxCursorPositionD=0;
- int subVar= -1;
- int stats_var;
- int compare_stats;
- byte downArrow[8] = {
- 0b00100, // *
- 0b00100, // *
- 0b00100, // *
- 0b00100, // *
- 0b00100, // *
- 0b10101, // * * *
- 0b01110, // ***
- 0b00100 // *
- };
- byte upArrow[8] = {
- 0b00100, // *
- 0b01110, // ***
- 0b10101, // * * *
- 0b00100, // *
- 0b00100, // *
- 0b00100, // *
- 0b00100, // *
- 0b00100 // *
- };
- byte menuCursor[8] = {
- B01000, // *
- B00100, // *
- B00010, // *
- B00001, // *
- B00010, // *
- B00100, // *
- B01000, // *
- B00000 //
- };
- #include <SPI.h>
- #include <SD.h>
- #include "DHT.h"
- #include <Wire.h>
- #include <LiquidCrystal.h>
- #include <IRremote.h>
- IRsend irsend;
- // Setting the LCD shields pins
- LiquidCrystal lcd(44, 46, 4, 5, 6, 7);
- #define DHTPIN 8
- #define DHTTYPE DHT11
- DHT dht(DHTPIN, DHTTYPE);
- void setup() {
- // Initializes serial communication
- Serial.begin(9600);
- while(menuItems[maxCursorPosition]!=""){maxCursorPosition++;}
- maxCursorPosition--;
- maxMenuPages= maxCursorPosition;
- if(maxMenuPages>=1)maxMenuPages -= 1;
- while(subMenu[maxCursorPositionS]!=""){maxCursorPositionS++;}
- maxCursorPositionS--;
- maxSubPages= maxCursorPositionS;
- if(maxSubPages>=1)maxSubPages -= 1;
- while(subMenu1[maxCursorPositionD]!=""){maxCursorPositionD++;}
- maxCursorPositionD--;
- maxSubPagesD= maxCursorPositionD;
- if(maxSubPagesD>=1)maxSubPagesD -= 1;
- // Initializes and clears the LCD screen
- lcd.begin(16, 2);
- lcd.clear();
- dht.begin();
- // Creates the byte for the 3 custom characters
- lcd.createChar(0, menuCursor);
- lcd.createChar(1, upArrow);
- lcd.createChar(2, downArrow);
- attachInterrupt(digitalPinToInterrupt(rxPinIR), rxIR_Interrupt_Handler, CHANGE);//set up ISR for receiving IR signal
- }
- void loop() {
- if(subVar == -1) {
- mainMenuDraw();
- drawCursor();
- operateMainMenu();
- } else if (subVar == 0){
- subMenuDraw();
- subCursorDraw();
- operateSub();
- }
- else if (subVar == 1){
- subMenuDrawD();
- subCursorDrawD();
- operateSubD();
- }
- }
- void mainMenuDraw() {
- Serial.print(menuPage);
- lcd.clear();
- lcd.setCursor(1, 0);
- lcd.print(menuItems[menuPage]);
- lcd.setCursor(1, 1);
- lcd.print(menuItems[menuPage + 1]);
- if (menuPage == 0) {
- lcd.setCursor(15, 1);
- lcd.write(byte(2));
- } else if (menuPage > 0 and menuPage < maxMenuPages) {
- lcd.setCursor(15, 1);
- lcd.write(byte(2));
- lcd.setCursor(15, 0);
- lcd.write(byte(1));
- } else if (menuPage == maxMenuPages) {
- lcd.setCursor(15, 0);
- lcd.write(byte(1));
- }
- }
- void drawCursor() {
- for (int x = 0; x < 2; x++) { // Erases current cursor
- lcd.setCursor(0, x);
- lcd.print(" ");
- }
- if (menuPage % 2 == 0) {
- if (cursorPosition % 2 == 0) { // If the menu page is even and the cursor position is even that means the cursor should be on line 1
- lcd.setCursor(0, 0);
- lcd.write(byte(0));
- }
- if (cursorPosition % 2 != 0) { // If the menu page is even and the cursor position is odd that means the cursor should be on line 2
- lcd.setCursor(0, 1);
- lcd.write(byte(0));
- }
- }
- if (menuPage % 2 != 0) {
- if (cursorPosition % 2 == 0) { // If the menu page is odd and the cursor position is even that means the cursor should be on line 2
- lcd.setCursor(0, 1);
- lcd.write(byte(0));
- }
- if (cursorPosition % 2 != 0) { // If the menu page is odd and the cursor position is odd that means the cursor should be on line 1
- lcd.setCursor(0, 0);
- lcd.write(byte(0));
- }
- }
- }
- void operateMainMenu() {
- int activeButton = 0;
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 0: // When button returns as 0 there is no action taken
- break;
- case 1: // This case will execute if the "forward" button is pressed
- button = 0;
- switch (cursorPosition) { // The case that is selected here is dependent on which menu page you are on and where the cursor is.
- case 0:
- break;
- case 1:
- menuItem1();
- break;
- case 2:
- subVar=0;
- break;
- case 3:
- subVar=1;
- //menuItem3();
- break;
- case 4:
- menuItem4();
- }
- activeButton = 1;
- mainMenuDraw();
- drawCursor();
- break;
- case 2:
- button = 0;
- if (menuPage == 0) {
- cursorPosition = cursorPosition - 1;
- cursorPosition = constrain(cursorPosition, 0, maxCursorPosition);
- }
- if (menuPage % 2 == 0 and cursorPosition % 2 == 0) {
- menuPage = menuPage - 1;
- menuPage = constrain(menuPage, 0, maxMenuPages);
- }
- if (menuPage % 2 != 0 and cursorPosition % 2 != 0) {
- menuPage = menuPage - 1;
- menuPage = constrain(menuPage, 0, maxMenuPages);
- }
- cursorPosition = cursorPosition - 1;
- cursorPosition = constrain(cursorPosition, 0, maxCursorPosition);
- mainMenuDraw();
- drawCursor();
- activeButton = 1;
- break;
- case 3:
- button = 0;
- if (menuPage % 2 == 0 and cursorPosition % 2 != 0) {
- menuPage = menuPage + 1;
- menuPage = constrain(menuPage, 0, maxMenuPages);
- }
- if (menuPage % 2 != 0 and cursorPosition % 2 == 0) {
- menuPage = menuPage + 1;
- menuPage = constrain(menuPage, 0, maxMenuPages);
- }
- cursorPosition = cursorPosition + 1;
- cursorPosition = constrain(cursorPosition, 0, maxCursorPosition);
- activeButton = 1;
- mainMenuDraw();
- drawCursor();
- }}}
- int evaluateButton(int x) {
- int result = 0;
- if (x < 50) {
- result = 1; // right
- } else if (x < 195) {
- result = 2; // up
- } else if (x < 380) {
- result = 3; // down
- } else if (x < 790) {
- result = 4; // left
- }
- return result;
- }
- void drawInstructions() {
- lcd.setCursor(0, 1); // Set cursor to the bottom line
- lcd.print("Use ");
- lcd.write(byte(1)); // Up arrow
- lcd.print("/");
- lcd.write(byte(2)); // Down arrow
- lcd.print(" buttons");
- }
- void menuItem1() { // Function executes when you select the 3rd item from main menu
- int activeButton = 0;
- lcd.clear();
- lcd.begin(16, 2);
- dht.begin();
- lcd.print("Temp: Humidity:");
- lcd.setCursor(0, 1);
- float h = dht.readHumidity();
- float f = dht.readTemperature(true);
- if (isnan(h) || isnan(f)) {
- lcd.print("ERROR");
- return;
- }
- float f1;
- f1=(f-36)*5/9;
- lcd.print(round(f1));
- lcd.print(" C");
- lcd.setCursor(7,1);
- lcd.print(h);
- lcd.print("%");
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void menuItem4() { // Function executes when you select the 4th item from main menu
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Int SD...");
- if (!SD.begin(chipSelect)) {
- lcd.clear();
- lcd.print("Failed!");
- while (1);
- }
- delay(1000);
- lcd.clear();
- lcd.print("Card ok!");
- lcd.clear();
- delay(1000);
- lcd.print("Prepare...");
- delay(2000);
- lcd.clear();
- lcd.print("Press ON");
- Adding();
- delay(2000);
- lcd.clear();
- lcd.print("Press OFF");
- Adding();
- delay(2000);
- lcd.clear();
- lcd.print("Press Temp up");
- Adding();
- delay(2000);
- lcd.clear();
- lcd.print("Press Temp down");
- Adding();
- delay(2000);
- lcd.clear();
- lcd.print("Registered!");
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Adding(){
- {
- // make a string for assembling the data to log:
- String dataString = "";
- delay(3000); // pause 5 secs
- if (x) { //if a signal is captured
- delay(3000);
- dataString += "Raw: ("; //dump raw header format - for library
- dataString += (x - 1);
- dataString += ") ";
- detachInterrupt(digitalPinToInterrupt(rxPinIR));//stop interrupts & capture until finshed here
- for (int i = 1; i < x; i++) { //now dump the times
- if (!(i & 0x1)) dataString += "";
- dataString += (irBuffer[i] - irBuffer[i - 1]);
- dataString += F(", ");
- }
- x = 0;
- attachInterrupt(digitalPinToInterrupt(rxPinIR), rxIR_Interrupt_Handler, CHANGE);//re-enable ISR for receiving IR signal
- }
- File dataFile = SD.open("Remotes.txt", FILE_WRITE);
- // if the file is available, write to it:
- if (dataFile) {
- dataFile.println(dataString);
- dataFile.close();
- }
- delay(1000);
- lcd.clear();
- lcd.print("Added!");
- }
- }
- void sendSamsung_ON(){
- int khz = 38;
- unsigned int irSignal[] = {3016, 9016, 472, 576, 560, 1480, 532, 536, 484, 560, 560, 484, 536, 512, 556, 508, 536, 512, 524, 520, 560, 1504, 484, 560, 560, 484, 560, 1500, 520, 524, 564, 484, 556, 1504, 560, 1484, 488, 1568, 536, 1528, 520, 1516, 560, 512, 508, 536, 552, 544, 560, 484, 560, 484, 560, 508, 536, 512, 540, 504, 536, 508, 560, 512, 508, 536, 560, 536, 512, 532, 536, 508, 536, 536, 468, 576, 484, 560, 560, 484, 560, 508, 540, 504, 540, 508, 524, 520, 588, 488, 532, 536, 484, 560, 532, 512, 560, 508, 512, 532, 520, 528, 532, 512, 536, 508, 532, 536, 468, 1572, 560, 1500, 560, 1480, 536, 1524, 508, 1624, 2992, 9020, 516, 1524, 536, 508, 560, 508, 532, 508, 564, 488, 560, 484, 560, 508, 536, 508, 520, 524, 564, 1504, 464, 576, 532, 512, 564, 1500, 484, 560, 560, 484, 560, 488, 556, 1504, 560, 1500, 520, 1520, 560, 1556, 556, 1480, 560, 1504, 556, 1504, 540, 1500, 556, 1504, 560, 484, 560, 488, 556, 508, 536, 512, 512, 532, 560, 484, 560, 508, 536, 512, 508, 536, 560, 536, 560, 484, 564, 484, 556, 512, 484, 560, 560, 1500, 540, 1528, 556, 516, 460, 580, 548, 496, 560, 1504, 464, 580, 560, 484, 560, 508, 540, 504, 540, 500, 540, 512, 560, 488, 612, 1500, 560, 1480, 560, 1500, 560, 1500, 508};
- irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
- }
- void sendDaewoo_ON(){
- int khz = 38;
- unsigned int irSignal[] = {3128, 1596, 532, 1064, 532, 1064, 532, 216, 612, 216, 612, 216, 612, 1064, 532, 216, 612, 220, 608, 1064, 532, 1064, 532, 216, 584, 1088, 532, 220, 608, 220, 608, 1064, 532, 1064, 532, 220, 608, 1064, 532, 1064, 532, 216, 612, 216, 612, 1064, 528, 220, 612, 216, 612, 1064, 532, 216, 612, 216, 612, 216, 612, 220, 608, 216, 608, 224, 608, 220, 608, 220, 608, 220, 608, 220, 608, 216, 612, 220, 608, 220, 608, 220, 608, 220, 612, 216, 612, 216, 612, 1064, 528, 220, 608, 224, 604, 1064, 536, 216, 612, 216, 612, 1064, 532, 1060, 532, 220, 612, 216, 612, 216, 612, 216, 612, 216, 612, 216, 612, 220, 608, 220, 612, 212, 612, 1064, 532, 220, 612, 212, 612, 220, 612, 220, 608, 216, 612, 216, 612, 216, 612, 216, 612, 220, 608, 216, 612, 1064, 532, 220, 612, 216, 608, 220, 612, 212, 612, 220, 612, 216, 612, 216, 612, 216, 612, 216, 612, 216, 612, 216, 612, 216, 612, 216, 612, 216, 616, 212, 612, 216, 612, 220, 612, 212, 616, 212, 616, 212, 616, 212, 616, 216, 612, 216, 612, 216, 612, 216, 616, 212, 616, 212, 612, 216, 612, 220, 612, 212, 612, 216, 616, 212, 612, 1064, 536, 216, 612, 212, 616, 1060, 532, 216, 612, 220, 612, 208, 620, 212, 616, 212, 616};
- irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
- }
- void sendSamsung_OFF(){
- int khz = 38;
- unsigned int irSignal[] = {3044, 8996, 512, 532, 560, 1500, 540, 508, 540, 504, 560, 460, 584, 508, 540, 508, 512, 532, 560, 484, 560, 1500, 552, 496, 560, 484, 560, 1500, 592, 1500, 516, 528, 560, 1500, 488, 1548, 564, 1500, 564, 1528, 560, 1500, 560, 484, 560, 488, 560, 508, 536, 512, 560, 480, 588, 508, 564, 508, 564, 480, 588, 508, 564, 508, 560, 484, 588, 484, 588, 508, 560, 508, 564, 484, 588, 504, 564, 512, 560, 508, 492, 580, 512, 556, 524, 544, 540, 536, 536, 532, 540, 532, 568, 500, 576, 496, 580, 492, 584, 484, 588, 484, 592, 480, 588, 480, 592, 480, 588, 480, 592, 480, 588, 1500, 544, 1548, 460, 1288, 2996, 9016, 548, 1492, 560, 508, 536, 508, 516, 528, 564, 480, 564, 508, 536, 508, 512, 532, 560, 460, 588, 1500, 516, 528, 560, 484, 564, 508, 536, 508, 512, 528, 568, 1520, 568, 1500, 560, 1500, 516, 1524, 596, 1488, 564, 484, 564, 504, 540, 508, 540, 504, 564, 480, 564, 504, 540, 508, 560, 456, 616, 484, 588, 480, 588, 484, 588, 480, 592, 480, 588, 508, 564, 484, 584, 460, 612, 1500, 552, 1540, 560, 532, 540, 532, 536, 532, 540, 532, 512, 560, 540, 532, 536, 1496, 568, 480, 560, 1500, 564, 484, 560, 1524, 540, 532, 564, 508, 536, 536, 536, 532, 564, 508, 552, 516, 540, 536, 508, 1196, 2972, 9040, 560, 1552, 540, 532, 564, 512, 552, 512, 488, 584, 564, 508, 560, 512, 512, 556, 564, 508, 560, 1504, 488, 556, 560, 484, 560, 1500, 560, 1504, 560, 508, 560, 508, 568, 1496, 568, 1496, 472, 1564, 568, 1524, 564, 1496, 520, 1520, 560, 1500, 564, 1524, 560, 1480, 560, 508, 488, 556, 564, 480, 564, 484, 560, 512, 560, 484, 584, 512, 560, 512, 560, 508, 488, 580, 516, 556, 516, 552, 540, 504, 572, 532, 580, 1476, 564, 1500, 516, 528, 564, 508, 536, 484, 560, 1504, 564, 528, 544, 528, 572, 484, 588, 480, 596, 480, 596, 484, 592, 480, 588, 484, 588, 484, 584, 1476, 564, 1496, 512};
- irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
- }
- void sendDaewoo_OFF(){
- int khz = 38;
- unsigned int irSignal[] = {2392, 6188, 288, 7724, 288, 456, 344, 6852, 264, 2960, 252, 604, 296, 5464, 296, 26696, 288, 13032, 292, 6272, 264, 400, 288, 1456, 264, 8036, 292, 1240, 256, 9088, 264, 5148, 284, 2148, 268, 1428, 340, 62128, 3128, 1600, 528, 1064, 532, 1064, 532, 220, 608, 216, 612, 220, 608, 1064, 532, 220, 608, 224, 604, 1064, 532, 1064, 532, 220, 608, 1064, 528, 224, 604, 224, 608, 1064, 528, 1064, 532, 224, 604, 1064, 532, 1068, 528, 224, 604, 224, 604, 1068, 528, 224, 604, 224, 604, 1064, 532, 224, 608, 216, 612, 220, 604, 224, 604, 224, 608, 220, 608, 220, 608, 220, 608, 220, 608, 224, 604, 220, 608, 220, 608, 224, 604, 220, 608, 228, 604, 220, 608, 220, 604, 224, 608, 220, 608, 220, 608, 1064, 508, 272, 576, 228, 604, 1064, 532, 1064, 528, 224, 604, 224, 604, 224, 604, 224, 604, 228, 604, 224, 604, 1064, 532, 220, 608, 220, 608, 1064, 532, 220, 604, 228, 604, 220, 608, 224, 604, 224, 604, 224, 604, 224, 604, 224, 604, 224, 604, 224, 604, 1064, 532, 228, 600, 224, 604, 228, 604, 220, 608, 220, 604, 228, 604, 220, 608, 224, 604, 224, 604, 224, 604, 224, 604, 224, 604, 224, 604, 224, 608, 220, 604, 224, 604, 224, 604, 224, 608, 220, 608, 220, 608, 220, 608, 224, 600, 228, 604, 224, 604, 224, 604, 224, 604, 224, 608, 216, 608, 228, 604, 220, 608, 220, 608, 220, 608, 1064, 528, 1068, 532, 220, 608, 220, 608, 220, 608, 224, 604, 220, 608, 220, 584, 272, 580};
- irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
- }
- void subMenuDraw() {
- Serial.print(subPage);
- lcd.clear();
- lcd.setCursor(1, 0);
- lcd.print(subMenu[subPage]);
- lcd.setCursor(1, 1);
- lcd.print(subMenu[subPage + 1]);
- if (subPage == 0) {
- lcd.setCursor(15, 1);
- lcd.write(byte(2));
- } else if (subPage > 0 and subPage < maxSubPages) {
- lcd.setCursor(15, 1);
- lcd.write(byte(2));
- lcd.setCursor(15, 0);
- lcd.write(byte(1));
- } else if (subPage == maxSubPages) {
- lcd.setCursor(15, 0);
- lcd.write(byte(1));
- }
- }
- void subCursorDraw() {
- for (int x = 0; x < 2; x++) { // Erases current cursor
- lcd.setCursor(0, x);
- lcd.print(" ");
- }
- if (subPage % 2 == 0) {
- if (subCursor % 2 == 0) { // If the menu page is even and the cursor position is even that means the cursor should be on line 1
- lcd.setCursor(0, 0);
- lcd.write(byte(0));
- }
- if (subCursor % 2 != 0) { // If the menu page is even and the cursor position is odd that means the cursor should be on line 2
- lcd.setCursor(0, 1);
- lcd.write(byte(0));
- }
- }
- if (subPage % 2 != 0) {
- if (subCursor % 2 == 0) { // If the menu page is odd and the cursor position is even that means the cursor should be on line 2
- lcd.setCursor(0, 1);
- lcd.write(byte(0));
- }
- if (subCursor % 2 != 0) { // If the menu page is odd and the cursor position is odd that means the cursor should be on line 1
- lcd.setCursor(0, 0);
- lcd.write(byte(0));
- }
- }
- }
- void operateSub() {
- int activeButton = 0;
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 0: // When button returns as 0 there is no action taken
- break;
- case 1: // This case will execute if the "forward" button is pressed
- button = 0;
- switch (subCursor) { // The case that is selected here is dependent on which menu page you are on and where the cursor is.
- case 0:
- Temp17();
- break;
- case 1:
- Temp18();
- break;
- case 2:
- Temp19();
- break;
- case 3:
- Temp20();
- break;
- case 4:
- Temp21();
- break;
- case 5:
- Temp22();
- break;
- case 6:
- Temp23();
- break;
- case 7:
- Temp24();
- break;
- case 8:
- Temp25();
- break;
- case 9:
- subVar=-1;
- break;
- }
- activeButton = 1;
- subMenuDraw();
- subCursorDraw();
- break;
- case 2:
- button = 0;
- if (subPage == 0) {
- subCursor = subCursor - 1;
- subCursor = constrain(subCursor, 0, maxCursorPositionS);
- }
- if (subPage % 2 == 0 and subCursor % 2 == 0) {
- subPage = subPage - 1;
- subPage = constrain(subPage, 0, maxSubPages);}
- if (subPage % 2 != 0 and subCursor % 2 != 0) {
- subPage = subPage - 1;
- subPage = constrain(subPage, 0, maxSubPages);
- }
- subCursor = subCursor - 1;
- subCursor = constrain(subCursor, 0, maxCursorPositionS);
- subMenuDraw();
- subCursorDraw();
- activeButton = 1;
- break;
- case 3:
- button = 0;
- if (subPage % 2 == 0 and subCursor % 2 != 0) {
- subPage = subPage + 1;
- subPage = constrain(subPage, 0, maxSubPages);
- }
- if (subPage % 2 != 0 and subCursor % 2 == 0) {
- subPage = subPage + 1;
- subPage = constrain(subPage, 0, maxSubPages);
- }
- subCursor = subCursor + 1;
- subCursor = constrain(subCursor, 0, maxCursorPositionS);
- activeButton = 1;
- subMenuDraw();
- subCursorDraw();
- }
- }
- }
- void Temp17() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 17 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=17;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Temp18() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 18 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=18;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Temp19() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 19 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=19;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();;
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Temp20() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 20 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=20;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action req");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Temp21() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 21 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=21;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Temp22() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 22 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=22;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Temp23() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 23 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=23;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Temp24() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 24 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=24;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void Temp25() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 25 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=24;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendSamsung_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void subMenuDrawD() {
- Serial.print(subPageD);
- lcd.clear();
- lcd.setCursor(1, 0);
- lcd.print(subMenu1[subPageD]);
- lcd.setCursor(1, 1);
- lcd.print(subMenu1[subPageD + 1]);
- if (subPageD == 0) {
- lcd.setCursor(15, 1);
- lcd.write(byte(2));
- } else if (subPageD > 0 and subPageD < maxSubPagesD) {
- lcd.setCursor(15, 1);
- lcd.write(byte(2));
- lcd.setCursor(15, 0);
- lcd.write(byte(1));
- } else if (subPageD == maxSubPagesD) {
- lcd.setCursor(15, 0);
- lcd.write(byte(1));
- }
- }
- void subCursorDrawD() {
- for (int x = 0; x < 2; x++) { // Erases current cursor
- lcd.setCursor(0, x);
- lcd.print(" ");
- }
- if (subPageD % 2 == 0) {
- if (subCursorD % 2 == 0) { // If the menu page is even and the cursor position is even that means the cursor should be on line 1
- lcd.setCursor(0, 0);
- lcd.write(byte(0));
- }
- if (subCursorD % 2 != 0) { // If the menu page is even and the cursor position is odd that means the cursor should be on line 2
- lcd.setCursor(0, 1);
- lcd.write(byte(0));
- }
- }
- if (subPageD % 2 != 0) {
- if (subCursorD % 2 == 0) { // If the menu page is odd and the cursor position is even that means the cursor should be on line 2
- lcd.setCursor(0, 1);
- lcd.write(byte(0));
- }
- if (subCursorD % 2 != 0) { // If the menu page is odd and the cursor position is odd that means the cursor should be on line 1
- lcd.setCursor(0, 0);
- lcd.write(byte(0));
- }
- }
- }
- void operateSubD() {
- int activeButton = 0;
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 0: // When button returns as 0 there is no action taken
- break;
- case 1: // This case will execute if the "forward" button is pressed
- button = 0;
- switch (subCursorD) { // The case that is selected here is dependent on which menu page you are on and where the cursor is.
- case 0:
- TempD17();
- break;
- case 1:
- TempD18();
- break;
- case 2:
- TempD19();
- break;
- case 3:
- TempD20();
- break;
- case 4:
- TempD21();
- break;
- case 5:
- TempD22();
- break;
- case 6:
- TempD23();
- break;
- case 7:
- TempD24();
- break;
- case 8:
- TempD25();
- break;
- case 9:
- subVar=-1;
- break;
- }
- activeButton = 1;
- subMenuDrawD();
- subCursorDrawD();
- break;
- case 2:
- button = 0;
- if (subPageD == 0) {
- subCursorD = subCursorD - 1;
- subCursorD = constrain(subCursorD, 0, maxCursorPositionD);
- }
- if (subPageD % 2 == 0 and subCursorD % 2 == 0) {
- subPageD = subPageD - 1;
- subPageD = constrain(subPageD, 0, maxSubPagesD);}
- if (subPageD % 2 != 0 and subCursorD % 2 != 0) {
- subPageD = subPageD - 1;
- subPageD = constrain(subPageD, 0, maxSubPagesD);
- }
- subCursorD = subCursorD - 1;
- subCursorD = constrain(subCursorD, 0, maxCursorPositionD);
- subMenuDraw();
- subCursorDraw();
- activeButton = 1;
- break;
- case 3:
- button = 0;
- if (subPageD % 2 == 0 and subCursorD % 2 != 0) {
- subPageD = subPageD + 1;
- subPageD = constrain(subPageD, 0, maxSubPagesD);
- }
- if (subPageD % 2 != 0 and subCursorD % 2 == 0) {
- subPageD = subPageD + 1;
- subPageD = constrain(subPageD, 0, maxSubPagesD);
- }
- subCursorD = subCursorD + 1;
- subCursorD = constrain(subCursorD, 0, maxCursorPositionD);
- activeButton = 1;
- subMenuDrawD();
- subCursorDrawD();
- }
- }
- }
- void TempD17() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 17 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=17;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void TempD18() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 18 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=18;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void TempD19() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 19 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=19;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void TempD20() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 20 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=20;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action req");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void TempD21() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 21 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=21;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void TempD22() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 22 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=22;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void TempD23() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 23 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=23;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void TempD24() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 24 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=24;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- void TempD25() {
- int activeButton = 0;
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("Temp 25 selected");
- delay(1000);
- lcd.clear();
- lcd.print("Scanning...");
- stats_var=24;
- compare_stats=Temperature_Scan();
- delay(1000);
- lcd.clear();
- if (stats_var == compare_stats){
- lcd.print("Temp is ok");
- lcd.clear();
- lcd.print("No action");}
- if (stats_var < compare_stats){
- lcd.print("Temp higher");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- if (stats_var > compare_stats){
- lcd.print("Temp lower");
- delay(1000);
- lcd.clear();
- lcd.print("Turning AC on...");
- delay(1000);
- sendDaewoo_ON();
- lcd.clear();
- lcd.print("AC on!");
- lcd.setCursor(0,1);
- lcd.print("<-:Back");}
- while (activeButton == 0) {
- int button;
- readKey = analogRead(0);
- if (readKey < 790) {
- delay(100);
- readKey = analogRead(0);
- }
- button = evaluateButton(readKey);
- switch (button) {
- case 4: // This case will execute if the "back" button is pressed
- button = 0;
- activeButton = 1;
- break;
- }
- }
- }
- int Temperature_Scan() {
- float f1 = dht.readTemperature(true);
- float t_c;
- t_c=(f1-36)*5/9;
- return round(t_c);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement