TED FITES
Published © GPL3+

Manual-Automatic Whole House Attic Fan Controller

Argon micro-controller converts a 3-speed floor fan into a whole-house air circulation system. Buttons select manual/auto fan operation

IntermediateShowcase (no instructions)Over 2 days494
Manual-Automatic Whole House Attic Fan Controller

Things used in this project

Hardware components

Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Argon
Particle Argon
Breadboard micro-controller
×1
Gikfun 12x12x7.3 mm Tact Tactile Push Button Momentary SMD PCB Switch with Cap for Arduino
Breadboard buttons
×2
Adafruit Monochrome 1.3" 128x64 OLED graphic display - STEMMA / Qwiic
Breadboard OLED display
×1
Humidity and Temperature Sensor
Adafruit Humidity and Temperature Sensor
Breadboard sensor
×1
ADDICORE 1 Channel Relay Module (Active Low Control)
Breadboard relay switch
×1
MOUSER BJT 2N3906 Transistor
Breadboard BJT transistor 2N3906
×1
Through Hole Resistor, 2.2 kohm
Through Hole Resistor, 2.2 kohm
Breadboard resistor from pin D7 to PNP base lead
×1
Through Hole Resistor, 120 ohm
Through Hole Resistor, 120 ohm
Breadboard resistor from VUSB 5V to PNP base-emitter lead base-emitter lead
×1
Item #758417 Model #SFD1-500B Utilitech 20-in 3-Speed Indoor Black Painting Personal Fan $79.98
Project attic fan, 3-speed, 20 in dia, circulates max 4500 CFM
×1
Item #4508 Model #PBD-09-00001 5/8-in x 2-ft x 2-ft Commercial Particle Board $4.64
Attic Fan Compartment Hardware: Particle board
×1
Item #36439Model #GVL0107 IMPERIAL 16-in x 36-in Galvanized Steel Joist Lining $7.98 (2)
Attic Fan Compartment Hardware: Compartment interior sheet metal lining
×2
Item #308961 Model #20902ORXLG Gatehouse 3.5-in Bronze Die-cast Sliding Window Sash Lift $3.18
Attic Fan Compartment Hardware: Compartment access door sash handle
×1
Item #35136 Model #B777CT40 Johns Manville Multi-Purpose R-5.33-sq ft Unfaced Fiberglass Roll Insulation (16-in W x 4-ft L) $5.90
Attic Fan Compartment Hardware: Compartment access door interior rolled insulation
×1
Item #63403 Model #180147 Hillman 1/4-in Zinc-Plated Standard (SAE) Nylon Insert Lock Nut 0.13 (3)
Attic Fan Compartment Hardware: Lock nut--works with flat brace
×3
Item #19165 Model #SP115BC Stanley-National Hardware 0.875-in x 4-in x 3.98-in Zinc-plated Flat Brace $3.27 (3)
Attic Fan Compartment Hardware: Angled brace connected to #69811 for securing fan
×3
Item #69811 Model #11139 Hillman 1-3/8-in x 3-ft Interior/Exterior Zinc-Plated Steel Perforated $5.98 (2)
Attic Fan Compartment Hardware: Flat perforated tie brace to secure fan in place
×2
Item #333358 Model #991210 1 x 8 x 8 PFJ Primed Board $16.98
Attic Fan Compartment Hardware: Compartment exterior lumber pc
×1
Item #63306 Model #270055 Hillman 1/4-in Zinc-Plated Standard (SAE) Flat Washer 0.13 (9)
Attic Fan Compartment Hardware: flat washer for hex bolts #61820
×9
Item #61820 Model #190003 Hillman 1/4-in x 1/2-in Zinc-Plated Coarse Thread Hex Bolt 0.09 (9)
Attic Fan Compartment Hardware: Hex bolts for angled braces
×9
Item #154277 Model #1502104 1/2 x 2 x 4 AC/BC Fir Plywood $11.75
Attic Fan Compartment Hardware: Compartment exterior lumber pc
×1
Item #648930 Model #N109-041 National Hardware 8/25-in Black Gate Hinge $4.78 (2)
Attic Fan Compartment Hardware: Compartment access door hinges
×2
Item #22249 Model #N222-232 National Hardware 1 Count 2.5-in W x 0.75-in L x 1/4-in Dia Zinc-plated U-Bolt
Attic Fan Compartment Hardware: U-bolt to secure closed access door
×1
Item #220376 Model #605565 Gatehouse 2-1/2in Brass Fixed Staple Safety Hasp
Attic Fan Compartment Hardware: Safety hasp to close compartment access door
×1
Item no.5301072|01-3414-456 Ace 0.73 in. L Zinc Gate Hook and Eye 1 pk
Attic Fan Compartment Hardware: Hook & eye securing access door in fully open position
×1
Item #777903 Model #PJ23LA-F-LW Eaton 2-Gang Light Almond Double Blank Midsize Wall Plate $1.84
Micro-controller wall attachment hardware: Breadboard wall attachment base
×1
Item #1614082 Model #1709-F-LW Eaton 15-Amp 125-Volt Heavy-Duty NEMA 5-15 Straight Plug $2.98
Attic fan power cord hardware: Cord 3-prong male plug-in
×1
Item #1614087 Model #2887-F-LW Eaton 15-Amp 125-Volt Heavy-Duty NEMA 5-15 Straight Connector $5.88
Attic fan power cord hardware: Cord 3-prong female connector
×1
Item #302632 Model #28827426 Southwire Romex SIMpull 15-ft 14/2 Non-Metallic Wire (By-the-Roll) $8.33
Attic fan power cord hardware: 15 ft Romex type NM-B cable (3-wire interior rated)
×1
Item #757555 Model #HST-187W Gardner Bender 5-Count 5mm 3-in Heat Shrink Tubing $2.48
Attic Fan Power Cord Conduit Hardware: Soldered wire joint heat shrink sheathing
×1
Item #68996 Model #330485 NMW1 Legrand 5 Ft White PVC Channel $7.97 (3)
Attic Fan Power Cord Conduit Hardware: 5 ft PVC channel sheathing pc
×3
Item #69112 Model #363145 NMW6 Legrand WM White Flat Elbow $4.47
Attic Fan Power Cord Conduit Hardware: Sheathing flat corner elbow pc
×1
Item #69613 Model #363148 NMW910 Legrand WMOLD Accessory Pack $3.47 (2)
Attic Fan Power Cord Conduit Hardware: Conduit accessory kit
×2

Software apps and online services

Windows 10 IoT Core
Microsoft Windows 10 IoT Core

Hand tools and fabrication machines

Item #478822 Model #SP25NKUS Weller Electric Lead-Free Soldering Kit $19.97
Attic Fan Power Cord wire -Relay Switch wire Connection: Soldering iron kit

Story

Read more

Schematics

AtticFanController Fritzing diagram

Main diagram illustrating micro-controller, including all connected breadboard components, relay switch connected from breadboard PNP circuit, and attic fan icon connected from relay switch

AtticFanController Export Breadboard diagram

Main diagram illustrating micro-controller and breadboard components exported in JPG format

AtticFanController Export Schematic Diagram

Main diagram illustrating schematic of breadboard components exported in JPG format

Code

AtticFanController Driver program

C/C++
Main driver program using Argon micro-controller and breadboard components to activate Utilitech floor fan repurposed as a whole house attic air circulation fan
/*
 * Project AtticFanController_FINAL
 * Description:
 *  This is a post-IoT Bootcamp project following the Cohort 2 graduation on Sep 11, 2020.
 *  This project repurposes a hi-power 3-speed floor fan for its new role as a whole house attic 
 * fan. Power for the fan is provided by constructing an active-mode PNP circuit connected to a 
 * relay switch, powered by an Argon Miccrocontroller. The fan circulates air throughout the house,
 * concentrating into a custom-built ceiling compartment that houses the fan, which fans air out 
 * into the attic space, and then exited via open garage windows.
 * 	The Argon is programmed with manual and automatic operating modes for fan control. Manual 
 * mode operates just like an on-off switch. Automatic mode continuously checks for interior 
 * temperature or humidity exceeding their programmed thresholds beforing powering on the fan. 
 * Separate OLED screens show programmed menu options to operate buttons for selecting the active 
 * operation mode.
 *  	The controller, active-mode PNP circuit and relay switch components can be adapted for 
 * controlling a variety of household A/C appliances, such as ceiling fans and electric heaters, 
 * whenever the relay switch circuit can be spliced into the device's hot wire of the power cord. 

 *
 * Author: Ted Fites
 * 
 * Modifications:
 * 10/29/20   TF Completed FINAL version. Includes final modifications for OLED screens button 
 *              operation screen messages and up-to-date source code file documentation.
 * 10/26/20   TF Completed v#3. Includes tested functionality for wrong button press during operation.
 * 10/25/20   TF Completed v#2. Includes tested functionality for controller AUTO mode complimentary
 *              to MANUAL mode. Also transferred circuit from Argon breadboard to small breakout board
 *              (2"x6") for added wiring space & to eliminate short circuits on Argon board.
 * 10/14/20   TF Created program. Includes tested intial functionality for controller MANUAL mode.
 *
 */
//************************************* HEADER section ***************************************
//********************* 1) Declare program header library files ******************************
#include "Adafruit_SSD1306.h"  // library to access class object for OLED display 
#include "Adafruit_BME280.h"  // library to access class object BME sensor
#define OLED_RESET D4

// ******************* 2) Declare global CONSTANTS & VARIABLES  ******************************
const bool ON=1, OFF=0;  // button switch variables clarifying main loop conditional checks logic
const float AUTO_MIN_TEMP=79.0, AUTO_MIN_HUM=99.0;  // initial AUTO mode threshold temperature/humidity values
const int ORIENT_PORTRAIT=3; // sets OLED button operation screen orientation to portrait
const int MAN_MODE_BTN_D10=D10;  // digital input pin# for YELLOW button (MANUAL mode) 
const int AUTO_MODE_BTN_D11=D11;  // digital input pin# for RED button (auto mode) 
const int FAN_ACTIVATION_D7=D7;  // digital output pin# supplying DC to activate (close) relay switch circuit
const unsigned long int POWER_OFF_DELAY=10000; // delay program 10 seconds following fan power-off
const unsigned long int BUTTON_PRESS_DELAY=1000; // delay main loop execution 1 second to recognize button press

bool btnManualSt, btnAutoSt;  // stores DigitalRead states from manual and auto button presses
bool autoFanStatus=OFF;  // intial setting used in AUTO mode checking if fan currently turned ON or OFF
bool manMode=OFF, autoMode=OFF; // initial settings checking which controller operation mode is currently in effect
bool status;  // activation status check for BME280 sensor
float temperature, humidity;  // variables storing data from BME analog sensor reads
// Next 2 variables display "catch-all" console error messages used during testing button operation (should never see)
String ErrMsgManOLED = "OLED DISPLAY SWITCH CASE ERROR--M A N U A L  MODE";
String ErrMsgAutoOLED = "OLED DISPLAY SWITCH CASE ERROR--A U T O MODE";
// Next 3 variables display on OLED screen during button operation
String OpsMsgAutoMode = "OPEN WIDE ATTIC DOOR& WINDOWS"; // fan prep reminder message for AUTO button press
String OpsMsgFrame = "!!!!!!!!!!";
String WrongButtonMsgFrame = "__________";
unsigned long int startMillis, currMillis, totDelay;  // for calculating program execution delays
enum SwPressErr {WRONG_YELLOW_PRESS,WRONG_RED_PRESS};  // User data type clarifying logic for invalid mode switch press
  SwPressErr en_SwPressErr;

// ******************* end CONSTANTS & VARIABLES  ******************************
// ******************* 3) Declare library class objects ************************
Adafruit_SSD1306 display(OLED_RESET); // object for OLED display methods 
Adafruit_BME280 bme;  // object for BME sensor's variables
//********************* end  HEADER section ************************************

SYSTEM_MODE(SEMI_AUTOMATIC); // Argon mode allows project flashing while disconnected from any wifi internet
void setup()  //***********************  S E T U P *****************************
{
  Serial.begin(9600);

// 1) Initialize the I2C address to 0x3C to activate the OLED display (128x64 pixels screen)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  
  display.display(); // show Adafruit splashscreen to OLED
  delay(1000);  // maintain display for 1 second
  Serial.printf("PROGRAM AtticFanController_FINAL\n");

 // 2) BME 280sensor : Execute .begin method to activate sensor  
  delay (1000);
  Serial.println(F("BME280 test"));   
  status = bme.begin(0x76);  
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),HEX);
        Serial.println("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085");
        Serial.println("   ID of 0x56-0x58 represents a BMP 280,");
        Serial.println("        ID of 0x60 represents a BME 280.");
        Serial.println("        ID of 0x61 represents a BME 680.");
        while (1);
    }
    else {
      Serial.println("BME280 Up and Running");
    }

// 3) Declare program PIN MODES 
pinMode(MAN_MODE_BTN_D10,INPUT_PULLDOWN); // YELLOW button pin: Manual fan control 
pinMode(AUTO_MODE_BTN_D11,INPUT_PULLDOWN);  // RED button pin: Automatic fan control 
pinMode(FAN_ACTIVATION_D7,OUTPUT);  // Digital pin to activate Relay switch to power attic fan

// 4) Display initial OLED screen in MANUAL operation display mode (manual switch set OFF)
ML01_MANUAL_OPS_SCREEN(OFF);  
}  // end SETUP

/*****************************************************************************************
 *************************************  M A I N  L O O P  ********************************
 *****************************************************************************************
 * B U T T O N  P R O C E S S I N G  L O G I C  O V E R V I E W ********************************
 * When pressing either button, YELLOW (for manual mode), or RED (for auto mode) use this same 
 * basic processing logic:
 * 1) Display the active OLED button operation screen for the operation mode the user selects. 
 * When the program starts, the MANUAL operation mode OLED screen displays.The active switch 
 * setting appears highlighted on the OLED display. For manual mode, switch settings are labeled 
 * "<MANUAL>" (for ON) and "<OFF>". For auto mode, switch settings are labeled "<RED>" (for ON) 
 * and "<OFF>". Also for auto mode, current temperature and humidity alues are highlighted on the 
 * display.
 * 2) Check for a YELLOW or RED button press (for manual or auto mode respectively). The initial
 * button press switches ON the selected operation mode.
 * 3) Check for a mistaken button SWITCH press. This occurs when the user has already switched ON
 * (activated) a selected operation mode (manual or auto). Instead of switching OFF the same 
 * selected mode by correctly repressing the same button, the user presses the opposite button. 
 * When this occurs, display an OLED message to press the correct button, then return the user 
 * back to the original screen and original switch setting (before the mistaken button press). 
 * 4) Upon correct button press, set the active mode's switch opposite to its current setting, in 
 * effect activating the switch (ON to OFF, OFF to ON).
 * 5) Redisplay the OLED button operation screen to display the highlighted new switch setting 
 * (changed in the previous step).
 * 6) Check for active mode as switched OFF. If it is switched OFF, then deactivate 
 * current flow sent through the digital output pin D7 (via digitalWrite set to LOW/NO voltage). 
 * In effect, this deactivates current flow to the relay switch, which opens the relay switch 
 * circuit to the spliced extension cord hot (black) wire, thereby shutting off power to the attic 
 * fan. This deactivation occurs and lasts only at the instant of the button press.
 * 7) Check for active mode as switched ON. If it is switched ON, then activate  
 * current flow sent through the digital output pin D7 (via digitalWrite set to HIGH 
 * voltage). In effect, after the button is pressed to turn the switch ON, this maintains activation 
 * of current flow to the relay switch, which keeps the relay switch circuit closed to the spliced 
 * extension cord hot (black) wire, thereby maintaining power to the attic fan.
 *  This logic sequence is repeated for each button press while the program runs.
 ***************************************************************************************************/ 
void loop() 
{
  btnManualSt=digitalRead(MAN_MODE_BTN_D10);  // Check: YELLOW button press
  btnAutoSt=digitalRead(AUTO_MODE_BTN_D11);  // Check: RED button press

  if (btnManualSt)  // **** M A N U A L  M O D E  SELECTED  **********************************
/************************* Y E L L O W  BUTTON PRESS PROCESSING   ****************************
 * This processing occurs upon the instantaneous YELLOW button press                         *
 * *******************************************************************************************/
  {
    if (autoMode == ON)  
    { // Check for RED button pressed out of turn (AUTO mode) when already in manual mode
      autoMode=OFF; // switch the wrong mode setting (AUTO) to OFF
      en_SwPressErr=WRONG_RED_PRESS;
      ML05_WRONG_BUTTON_DISPLAY_SCREEN(); // display OLED screen explaining error & correction instruction
      goto MainLoopBottom;  // exit to loop bottom, leaving on error screen, waiting for next button press
    }  
    else
    { // For a valid press, switch MANUAL mode opposite to its current setting, then redisplay 
      // the OLED screen showing the new switch setting.
      manMode = !manMode;
      ML01_MANUAL_OPS_SCREEN(manMode);  
    }

    if (manMode == OFF)
    { // Check for MANUAL mode switched OFF. If so, deactivate current flow to the relay switch
//      Serial.printf("manMode O F F > %i\n",manMode);
      digitalWrite(FAN_ACTIVATION_D7,LOW);
    }
  }  
/************************* e n d Y E L L O W  BUTTON PRESS PROCESSING   ********************/

/* Now perform a continuous loop check for MANUAL mode switched ON. If so, activate current flow 
* to the relay switch. Maintain this current flow to the relay while the switch stays ON. 
*/
  if (manMode == ON)
  { 
//    Serial.printf("manMode O N > %i\n",manMode);
    digitalWrite(FAN_ACTIVATION_D7,HIGH);
  }

  if (btnAutoSt)  // ***** A U T O  M O D E  SELECTED  ***************************************
/************************* R E D   BUTTON PRESS PROCESSING   *********************************
 * This processing occurs upon the instantaneous RED button press                            *
 * *******************************************************************************************/
  {
    if (manMode == ON)  
    {  // Check for YELLOW button pressed out of turn (MANUAL mode) when already in auto mode
      manMode=OFF;
      en_SwPressErr=WRONG_YELLOW_PRESS;
      ML05_WRONG_BUTTON_DISPLAY_SCREEN();
      goto MainLoopBottom;
    }      
    else
    {
      autoMode = !autoMode;
      ML02_AUTO_OPS_SCREEN(autoMode);
      Serial.printf("AUTOMode  > %i\n",autoMode);
    }
  /* Check if AUTO mode is switched off. Next, check if the fan is switched ON based  on either 
  * the temperature or humidity reaching their programmed thresholds. If so, then deactivate the 
  * fan, followed by a 10 second fan blade cessation period.
  */
    if (autoMode == OFF)
    {
      if (autoFanStatus == ON)
      {
        Serial.printf("MAIN LOOP:AUTOMode is O F F > %i\n",autoMode);
        autoFanStatus = OFF;
        digitalWrite(FAN_ACTIVATION_D7,LOW);
        ML04_TIME_DELAY(POWER_OFF_DELAY);     
      }
    }
  }  
/************************* e n d  R E D  BUTTON PRESS PROCESSING   ********************/

/* Now perform a continuous loop check for AUTO mode switched ON. While the switch is ON,
* perform a continuous, automatic check on the temperature and humidity thresholds to see
* if either threshold will trigger on the relay switch. Following the treshold checks, 
* redisplay the auto OLED screen to display continuously updated changes in temp or humidity.
*/
  if (autoMode == ON)
  {
    Serial.printf("AUTOMode is O N > %i execute ML03_CHECK_AUTO_THRESHOLDS()\n",autoMode);
    ML03_CHECK_AUTO_THRESHOLDS();
    ML02_AUTO_OPS_SCREEN(autoMode);
  }
MainLoopBottom:
  ML04_TIME_DELAY(BUTTON_PRESS_DELAY);     
}  
/****************************    end  M A I N  L O O P  ************************************
 *******************************************************************************************/ 

/********************   OLED DISPLAY: M A N U A L   O P  M O D E  **************************/
void ML01_MANUAL_OPS_SCREEN(bool inManMode)
{
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.setRotation(ORIENT_PORTRAIT);
  display.print("* MANUAL *");
  display.println();
  display.printf("<BUTTON>\n");
  display.printf("      MODE\n");
  display.printf("<YELLOW>\n");
  switch (inManMode)
  {
    case OFF:
      display.setTextColor(WHITE);
      display.printf("      ");
      display.setTextColor(BLACK,WHITE);
      display.printf("OFF\n");
      display.setTextColor(WHITE);
      display.printf("    MANUAL\n");
      display.printf("<RED> AUTO\n");
      break;
    case ON:
      display.setTextColor(WHITE);
      display.printf("      OFF\n");
      display.printf("    ");
      display.setTextColor(BLACK,WHITE);
      display.printf("MANUAL\n");
      display.setTextColor(WHITE);
      display.printf("<RED> AUTO\n");
      break;
    default:
      display.println(ErrMsgManOLED);
      break;
  }
  display.display();
  return;
}

/********************   OLED DISPLAY--UPPER SCREEN: A U T O  O P  M O D E  ************/
void ML02_AUTO_OPS_SCREEN(bool inAutoMode)
{
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.setRotation(ORIENT_PORTRAIT);
  display.print("*  AUTO  *");
  display.printf("<BUTTON>\n");
  display.printf("      MODE\n");
/* BUTTON OPERATION INSTRUCTIONS "STYLE" TO HIGHLIGHT ACTIVE AUTO MODE SETTING:
* Use .setTextColor "inverted" text settings to highlight either the target mode button ("RED"), 
* indicating the active operation mode (and implying it's also switched ON), OR the auto 
* mode's deactivate switch setting ("OFF"). This mode selection style differs from both highlighted 
* manual operation mode selection settings, demonstrating a hyper-concise operation selection 
* style adaptable to very small display screens.
*/
  switch (inAutoMode)
  {
    case OFF:
      display.printf("<RED>");
      display.setTextColor(BLACK,WHITE);
      display.printf(" OFF\n");
      display.setTextColor(WHITE);
      display.printf("<YELLOW>\n");     
      ML02_2_AUTO_OPS_SCREEN();
      break;
    case ON:
      display.setTextColor(BLACK,WHITE);
      display.printf("<RED>");
      display.setTextColor(WHITE);
      display.printf(" OFF\n");
      display.printf("<YELLOW>\n");     
      ML02_2_AUTO_OPS_SCREEN();
      break;
    default:
      display.println(ErrMsgAutoOLED);
      break;
  }      
  display.display();
  return;
}

/********************   OLED DISPLAY--LOWER SCREEN: A U T O  O P  M O D E  ************
* This function is called from its parent function (ML02_AUTO_OPS_SCREEN()) to finish displaying
* information to the auto mode display screen, and called from two locations, specific to which 
* is the active auto switch setting in effect. 
*/
void ML02_2_AUTO_OPS_SCREEN()
{
  display.setTextColor(WHITE);
  display.println();
  display.printf(" TEMP HUM\n");
  display.printf(" SETTINGS\n");
  display.printf(" %2.0f   %2.0f\n",AUTO_MIN_TEMP,AUTO_MIN_HUM);
  display.printf(" SENSOR\n");
  display.setTextColor(BLACK,WHITE);
  display.printf(" %2.0f",temperature);
  display.setTextColor(WHITE);
  display.printf("   ");
  display.setTextColor(BLACK,WHITE);
  display.printf("%2.0f\n",humidity);
  display.setTextColor(WHITE);
  display.print(OpsMsgFrame);
  display.println(OpsMsgAutoMode);
//  display.println(OpsMsgFrame);
  return;
}
void ML03_CHECK_AUTO_THRESHOLDS()
{
  temperature=bme.readTemperature() * (9.0/5.0) + 32.0;
  humidity=bme.readHumidity();
  Serial.printf("AUTOMode TEMPERATURE > %2.0f\n",temperature);
  Serial.printf("AUTOMode HUMIDITY > %2.0f\n",humidity);
  if ((temperature >= AUTO_MIN_TEMP) || (humidity >= AUTO_MIN_HUM))
  {
    autoFanStatus=ON;
    digitalWrite(FAN_ACTIVATION_D7,HIGH);
  }
  else
  {
    autoFanStatus=OFF;
    digitalWrite(FAN_ACTIVATION_D7,LOW);
  }
  return;
}

void ML04_TIME_DELAY(unsigned long int inDelay)
{
  startMillis=millis();
  currMillis=0;
  totDelay=startMillis + inDelay;
  while(currMillis < totDelay)
  {
    currMillis=millis();
  }
  return;
}

/********************   OLED DISPLAY:  W R O N G   B U T T O N   P R E S S   ************
* This display screen appears whenever the user doesn't use the selected button mode (manual or
* auto) as a proper toggle switch; that is, to press tha same button once to switch ON the operation
* mode, followed by a second press to switch OFF the mode. 
*/
void ML05_WRONG_BUTTON_DISPLAY_SCREEN()
{
  char strBtnYellow[10] = " YELLOW ";
  char strBtnRed[10] =    "  RED   ";
  char strOpModeMan[10] = " MANUAL ";
  char strOpModeAuto[10] ="  AUTO  ";

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.setRotation(ORIENT_PORTRAIT);
  display.print(WrongButtonMsgFrame);
  display.print("| PRESS  |");
  display.printf("|");
  display.setTextColor(BLACK,WHITE);
  switch (en_SwPressErr)
  {
    case WRONG_YELLOW_PRESS: 
      display.printf("%s",strBtnYellow);
      break;
    case WRONG_RED_PRESS:  
      display.printf("%s",strBtnRed);
      break;
  }
  display.setTextColor(WHITE);
  display.print("|");
  display.print("| BUTTON |");
  display.print("|   TO   |");
  display.print("| RETURN |");
  display.print("|   TO   |");
  display.print("|");
  display.setTextColor(BLACK,WHITE);
  switch (en_SwPressErr)
  {
    case WRONG_YELLOW_PRESS: 
      display.printf("%s",strOpModeMan);
      break;
    case WRONG_RED_PRESS:  
      display.printf("%s",strOpModeAuto);
      break;
  }
  display.setTextColor(WHITE);
  display.print("|");
  display.print("|  MODE  |");
  display.print(WrongButtonMsgFrame);
  display.display();
  return;
}

Credits

TED FITES

TED FITES

4 projects • 4 followers

Comments