Trying to replace a “Hard-Coded_Cool-Down/Wait-Delay” with TMP36 “control”.

This being my first “real” project (beyond Arduino’s built-in sketches), I am on that steep “C” learning curve. To see what the code (below) is all about, here is a 1-minute video of what-all is connected, and what I’m trying to achieve (apologies that the finger pointing does not follow my voice; I had to “Voice-Over” a couple of times).
[(-Eventually, I want to control 2 HD relays, for a “teeter-totter_motor-of-sorts”, among other things!-)]

Here is a pdf of the code that was actually on the UNO during that video filming.

So , the above “worked”, holding my HD coil “on” for however many ms I desired, and then, remaining “off” for however long I specified.

The difficulty now is:
I wish to replace the “hard_coded” Delay function (eliminate it altogether, so long as the temperature of my TMP36 sensor stays “reasonable”, once epoxied-to a real/working coil).

The code below represents where I am right now, after trying multitudes of things (including breaking up into several subroutines, calling each-in-turn, as desired), and adding braces “here-or-there” – attempting to “group things more properly”.
For example:
adding a “{“ brace at the end of line 39, and a “}“ brace between lines 46 & 47 causes immediate “alternating” of the Red/Green LEDs with corresponding contactor/coil energization [NO key-FOB button press necessary, it just starts-up automatically].

I have hammered-away for many weeks now, to no avail, and thus, must resort to “asking for guidance”… any-and-all of which will be MUCH appreciated (whether it is something that helps, or, simply tells me where I am “flat-out-goofing-up”)!

Current Code Status:

// This, below, now uploads successfully to Arduino UNO (having eliminated MANY errors) ; however,
// When the “Remote Relay” clicks “On” … “zero/zilch/nada” occurs down-the-line … except :
// as mentioned above, additional braces {} has caused “automatic runaway operation”.

  1. First ‘Declarations’ remain the same as in pdf, linked above.
    ~

  2. float voltage, degC, degF; // float = decimal# w/ digits ahead & behind

  3. long time = 0;

  4. boolean hot = false; // … cool-down called-for?

  5. long debounce = 50; // variable for “stateButton” test

  6. void setup() {

  7. pinMode(tempPin, INPUT); // TMP36 ‘sensor’ A0

  8. pinMode(pinButton, INPUT); // pinButton ; pulled LOW thru resistor

  9. pinMode(relay, OUTPUT); // Pin 7 - Relay controlling mega contactor

  10. pinMode(yellowLed, OUTPUT);

  11. pinMode(redLed, OUTPUT); // } all 3 LED pins are, obviously, “Outputs”

  12. pinMode(greenLed, OUTPUT);

  13. // Set-up the initial LED status (“Ready”)

  14. digitalWrite(yellowLed, LOW); // Yellow = “System is on-Hold”, not ready YET

  15. digitalWrite(redLed, HIGH); // Red = “System is Ready” to use , relay is “Off”

  16. digitalWrite(greenLed, LOW); // Green = “System_Firing” || relay is “On” !

  17. }

  18. void loop() { // All subroutines are ‘in the loop’

  19. voltage = analogRead(tempPin) * 0.004882814; // Converts 0-to-1023 to 0.0-5.0

  20. degC = (voltage - 0.5) * 100.0; // a conversion formula from spec-sheet(reverify)

  21. degF = degC * (9.0/5.0) + 32.0; // convert C to F

  22. lcd.begin(16,2); // WRITE-To LCD here

  23. lcd.print("Temperature is: ");

  24. lcd.setCursor(0,1);

  25. lcd.print(degF);

  26. stateButton = digitalRead(pinButton); // Check status of (Remote) button via its relay being used.

  27. if (degF < 175)

  28. if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {

  29. if(stateButton == HIGH){

  30. hot = false;

  31. digitalWrite(relay, LOW);

  32. digitalWrite(yellowLed, LOW);

  33. digitalWrite(greenLed, LOW);

  34. digitalWrite(redLed, HIGH);

  35. } else {

  36. hot = true;

  37. digitalWrite(relay, HIGH); // control-relay ON, to operate (High-Amp) relay

  38. digitalWrite(greenLed, HIGH); // “green” means Coil-Circuit is “hot”

  39. digitalWrite(redLed, LOW); // “red” goes Off, here

  40. digitalWrite(yellowLed, LOW); // “yellow” (“hold”) also goes Off, here

  41. delay(stayON); // “Stay_On” (control-relay) 1500ms.

  42. digitalWrite(relay, LOW); // AFTER “firing”, turn relay “Off”… and…

  43. digitalWrite(greenLed, LOW); // “green” goes Off, as Coil-Circuit is now “cold”

  44. digitalWrite(redLed, HIGH); // “red” goes On, here, reiterating “Ready”

  45. }

  46. time = millis();

  47. }

  48. previous = stateButton; // Y/N? “previous” is either “HIGH” or “LOW”

  49. if(hot == true && previous == HIGH) { // safetyCheck of sorts…

  50. digitalWrite(greenLed, LOW);

  51. digitalWrite(redLed, LOW);

  52. digitalWrite(yellowLed, HIGH); // Yellow “Cool-Down” initiated “on” [{led}]

  53. delay(5000); // still use a 5-sec default ‘delay’ / ‘Wait’…

  54. digitalWrite(greenLed, LOW); //…until TMP36 control is achieved.

  55. digitalWrite(redLed, HIGH);

  56. digitalWrite(yellowLed, LOW);

  57. {

  58. }

  59. } else

  60. if (degF > 175){

  61. while (degF > 150){

  62. voltage = analogRead(tempPin) * 0.004882814; // Converts 0-to-1023 to 0.0-5.0

  63. degC = (voltage - 0.5) * 100.0; // formula from spec-sheet(reverify)

  64. degF = degC * (9.0/5.0) + 32.0; // convert C to F

  65. lcd.begin(16,2); // WRITE-To LCD here

  66. lcd.print("Temperature is: ");

  67. lcd.setCursor(0,1);

  68. lcd.print(degF);

  69. digitalWrite(greenLed, LOW);

  70. digitalWrite(redLed, LOW);

  71. digitalWrite(yellowLed, HIGH);

  72. delay(1000); // needed to reduce LCD flickering

  73. }

  74. }

  75. else if (degF <= 150)

  76. voltage = analogRead(tempPin) * 0.004882814; // Converts 0-to-1023 to 0.0-5.0

  77. degC = (voltage - 0.5) * 100.0; // formula from spec-sheet(reverify)

  78. degF = degC * (9.0/5.0) + 32.0; // convert C to F

  79. lcd.begin(16,2); // WRITE-To LCD here

  80. lcd.print("Temperature is: ");

  81. lcd.setCursor(0,1);

  82. lcd.print(degF);

  83. digitalWrite(greenLed, LOW);

  84. digitalWrite(redLed, HIGH);

  85. digitalWrite(yellowLed, LOW);

  86. delay(1000); // needed to reduce LCD flickering

  87. {

  88. }

  89. } // End

? Where to go from here ? (Anyone?)

Please read the “how to use the forum-please read” stickies to see how to properly format and post code. See #7 (and #10). Please do not include line numbers. Please use autoformat (ctrl-t or Tools, Auto Format) to indent the code in a standard manner. Makes the code easier to follow (and debug).

The PDF link says “Access Denied”. Please post the code here per the above.

86. }
87. else if (degF <= 150)
88. voltage = analogRead(tempPin) * 0.004882814;  //  Converts 0-to-1023 to 0.0-5.0
89. degC = (voltage - 0.5) * 100.0;   //  formula from spec-sheet(reverify)

You need to learn how to use the curly brackets. For instance, in the code above, line 88 is the only line that will be executed conditionally when the else if is true. All the rest will always be executed unconditionally.

Why is lcd.begin() in loop(). Do you really need to initialize the lcd every time through loop()? Put begin in setup().

delay(1000);                                   // needed to reduce LCD flickering

Not so.
You get flicker due to the lcd.begin() call. Another common cause of flicker is lcd.clear().
Just overwrite the things on the LCD, clearing it by printing spaces. No flicker.

@ groundFungus — Sincere apologies here, I did not catch the “code brackets” while reading-down the How-to-Use page (lotsa info there). I spent an inordinate amount of time composing the Subject_Line alone, let-alone verifying “proper sentences” throughout(!)

I am baffled why the “Access Denied” message(?) That link is supposed to give “anybody” access to it (per “Google”)…(?)

It should be attached HERE, now. ((Q: Were you able to see the video?..“same drive”…))
The “Current State-of-Code” is attached as well.

You are absolutely correct in that I need to better understand the braces {}. As the referenced page states, it can be “confusing or daunting…the same curly braces replace the RETURN statement in a subroutine (function), the ENDIF statement in a conditional and the NEXT statement in a FOR loop.”
Coming into C from a background with (only) “archaic” HTML and Visual Basic has me “challenged” to say the least.

And thank-you for the (lcd) suggestion: “Put begin in setup()
There are numerous other things (from “borrowed/base code”) that I have yet to figure-out WHY (done-that-way).

@ wvmarle — “Marvelous!” Thank you for that tip as well.

I have ‘plugged-in’ these initial changes (see attached “Current_State”), and will “work at it some more”.

Thanks again !

Current_State_UNO_Code_(2-23-18pm).pdf (225 KB)

Original code (video’d)_.pdf (126 KB)

It would be better if you post your code, here, in code tags. People should not have to download your code to help you. See reply #1.

When you run the new code, what happens? How is that different from what is supposed to happen?

Thanks - As I was preparing my reply, here, I noticed something…((something DIFFERENT between the original code and the “Current State”)).

In the original code (as depicted in the first video) clicking the key-fob energizes the mini-relay (front-right in the video). This gets detected by the UNO, which then energizes the “Control Relay” (sitting just in front of the UNO), which in turn energizes the heavy-duty contactor, holding it on for 1500ms (subject to change later on). This all happened at “Line 12” in the “loop” [“digital-writing” control-relay High]:

void loop() { // “Original Code”, as in the video
hot = false;
stateButton = digitalRead(pinButton);
if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {
if(stateRelay == HIGH){
digitalWrite(relay, LOW);
digitalWrite(yellowLed, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(redLed, HIGH);
hot = false;
} else { // Line 12, below :
digitalWrite(relay, HIGH); // << HERE, things WERE working , before trying to
digitalWrite(greenLed, HIGH); // eliminate the “hard-coded” Delay, and add TMP36 control.
digitalWrite(redLed, LOW);
digitalWrite(yellowLed, LOW);
delay(stayON);
hot = true;
digitalWrite(relay, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(redLed, HIGH);
. . .

If you look at the “Current State code” (in the pdf, linked above) you will notice that where “Line5” immediately above says:

if(stateRelay == HIGH){ …

…the ORIGINAL code said “if(stateButton == HIGH){”
[[ “Doh!” ]]

SO : I made that change, back to “if(stateButton == HIGH){”
… and now …

When I first power-up the system (via the 12v supply), and click the remote, everything works as it should, BUT, “1-time-only”.

After the coil cycles on, then off (with the yellow led “cooperating”), the UNO will switch the “red” led back on ((indicating it is ready for operation again))… but, from this point on, no matter how many times the remote is pressed, the Arduino-controlled relay will NOT respond again until I unplug the 12v supply and “re-boot”.

“So far, so good” ! More improvement JUST TODAY, than in the past several weeks, having a couple extra “astute eyes” lending me some confidence!

I shall print the current code out, and “highlight/highlight/highlight” this weekend, trying to sort-out why it is “halting”, instead of “looping”. Thanks again!

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

So you have;

  • A remote operated input to the UNO
  • An LCD displaying ,eventually, temperature of the Sample to be heated.
  • An output on the UNO to control a contactor to a heating device.
  • Intially with power ON, you have RED LED to indicate power ON.
  • Operating the remote, the input of the UNO is activated.
  • The UNO output activates the contactor for 1500milliSeconds.
  • The GREEN LED is ON, during the contactor activation.
  • When the 1500milliSeconds has ended, the contactor is deactivated.
  • The GREEN LED goes OFF.
  • The YELLOW LED comes ON for a cooling down period.
  • While the YELLOW LED is ON, the remote input to the UNO is ignored.
  • When the cool down period has finished the YELLOW LED goes OFF and the process returns to STEP 1.

Your aim as I understand it is to incorporate the tempsensor so when you press the go button, the contactor is activated until the desired temperature is reached, then decactivated.

Then the process waits till the temperature gets below a certain temperature that is its cool down temp and the process goes back to step 1.

Can I suggest an other input that detects the power supply for the heater, this controls the RED LED and whether the process can start or not.

This looks like a "state machine" type code.

I would forget about de-bounce as you are only needing to detect the OFF to ON transition of the input, not the ON state.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Hi,
I have taken your code and changed it to switch…case type code.
I have put your temp and display codes in their own functions.
I have set the heater temp at 175.0F
I have added a cooldown temp to reset your code when the sample has got below a certain temp.
I have set that at 80.0F
You could simulate the temp changes with a soldering iron, or lower the two temp settings to run at a more easily simluated process.
It compiles, but I have not had the opportunity to see if it works in a UNO.
As I said you are only looking to see if the button has been pressed, so you do not need to de-bounce.
You may need to add a STOP button to halt the process before it has finished if you need to.

I hope the comments explain everything.
Feel free to play around with it.

#include <LiquidCrystal.h> // Library needed for LCD display

int tempPin = A0; // "Int-Var" for TMP36 sensor pin
int relayPin = 7; // “Int-Var” for Relay-Pin [7]
int buttonPin = 8; // “Int-Var” for buttonPin INput
int yellowLEDPin = 11; // "Int-Var” for Pin 11 - Yellow "cool-off" led
int redLEDPin = 12; // Red LED ~ Power is on, but Relay "off"
int greenLEDPin = 13; // Green ["Relay-is-On"] LED
int stateRelay = LOW; // Default state for Relay ("off")
int stateButton; // "Int-Var” “Placeholder/State” for Button
int stayON = 1500; // Coil stay on for 1500 ms
int previous = LOW; // const int temperaturePin = 0; JUST refer-to AS "A0"
const int rs = 9, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // Initialize Arduino -to- the connection-of-the-LCD

float voltage, degC, degF; // float = decimal# digits ahead & behind
long time = 0;
boolean hot = false; // Test whether cool-down is called-for
long debounce = 50; // variable for "stateButton" test


float tempSet = 175.0; // Set Temp for heater
float cooltempSet = 80.0; // Set Cooldown temp
byte processStatus = 0; // 0 = idle awaiting input  1 = heater activated (timed sequence)  2 = cooldown period

void setup() {
  pinMode(tempPin, INPUT); // TMP36 'sensor' A0
  pinMode(buttonPin, INPUT); // buttonPin ; pulled LOW thru resistor, til Remote > "On"
  pinMode(relayPin, OUTPUT); // Pin 7 - Relay controlling 500A contactor
  pinMode(yellowLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT); // } all 3 LED pins are, obviously, “Outputs”
  pinMode(greenLEDPin, OUTPUT);
  // Set-up the initial LED status (“Ready”)
  digitalWrite(yellowLEDPin, LOW); // Yellow = “System is on-Hold”, not ready-to-use YET.
  digitalWrite(redLEDPin, HIGH); // Red = “System is Ready” to use , relay is “Off”
  digitalWrite(greenLEDPin, LOW); // Green = “System_Firing” || relay is “On” !
  lcd.begin(16, 2); // ??? simply moving “begin” here caused the LCD to start writing
} // an “extra word” “Temperature” after the numeric degrees (?!?)
// I added the printing of “F” with extra “spaces” to eliminate that.

void loop() { // Everything is in our loop
  if (processStatus == 0) // if at idle, check button
  {
    stateButton = digitalRead(buttonPin); // Check status of (Remote) button via its relay being used.
    if (stateButton == HIGH)
    {
      processStatus = 1; // heating process activated.
    }
  }
  switch (processStatus)
  {
    case 0: // idle mode
      TempRead();
      TempDisplay();
      digitalWrite(relayPin, LOW);
      digitalWrite(yellowLEDPin, LOW);
      digitalWrite(greenLEDPin, LOW);
      digitalWrite(redLEDPin, HIGH);
      break;

    case 1:  // heating mode
      TempRead();
      TempDisplay();

      if (degF < tempSet)
      {
        digitalWrite(relayPin, HIGH);
        digitalWrite(yellowLEDPin, LOW);
        digitalWrite(greenLEDPin, HIGH);
        digitalWrite(redLEDPin, LOW);
      }
      else
      {
        processStatus = 2; // heating mode complete, go to cooldown mode
      }
      break;

    case 2: // cooling mode
      TempRead();
      TempDisplay();

      if (degF > cooltempSet)
      {
        digitalWrite(relayPin, LOW);
        digitalWrite(yellowLEDPin, HIGH);
        digitalWrite(greenLEDPin, LOW);
        digitalWrite(redLEDPin, LOW);
      }
      else
      {
        processStatus = 0; // cooling mode complete, go back to idle mode
      }
      break;
  }
}

//=== Functions======

void TempRead()
{
  voltage = analogRead(tempPin) * 0.004882814; // A0 | converts 0-to-1023 to 0.0-5.0
  degC = (voltage - 0.5) * 100.0; // a conversion formula from spec-sheet(reverify)
  degF = degC * (9.0 / 5.0) + 32.0; // conversion formula C to F
  return;
}

void TempDisplay()
{
  lcd.setCursor(0, 0);
  lcd.print("Temperature is: "); // WRITE-To LCD instructions here
  lcd.setCursor(0, 1);
  lcd.print("      ");  // to clear the temp reading for the next value.
  lcd.setCursor(0, 1);
  lcd.print(degF);
  lcd.print(" F "); // needed spaces to eliminate a "2nd_printing" of "Temperature" (?)
  return;
}

Tom… :slight_smile:

Thanks ever so much for taking the time... for the "detailed analysis"... and, for what looks to be a very "enlightening" suggestion (("state machine")).
One minor point, re: "Your aim as I understand it is to incorporate the tempsensor so when you press the go button, the contactor is activated until the desired temperature is reached, then decactivated."
Actually, the sole purpose of the TMP36 is to be able to help prevent overheating of the 'machine'... which, while being developed-and-tweaked, could potentially be subject-to (shall I simply say) "abuse".
I shall try to work-thru (i.e., "walk-myself-through") your code, and give an upload a try.
A cad sketch was, in fact, in the works, until the introduction of the Remote control and the TMP36 addition. I shall try to get THAT caught-up as well, and figure-out the best way to attach here.
Thanks again!

ArdFanIk:
Thanks ever so much for taking the time... for the "detailed analysis"... and, for what looks to be a very "enlightening" suggestion (("state machine")).
One minor point, re: "Your aim as I understand it is to incorporate the tempsensor so when you press the go button, the contactor is activated until the desired temperature is reached, then decactivated."
Actually, the sole purpose of the TMP36 is to be able to help prevent overheating of the 'machine'... which, while being developed-and-tweaked, could potentially be subject-to (shall I simply say) "abuse".
I shall try to work-thru (i.e., "walk-myself-through") your code, and give an upload a try.
A cad sketch was, in fact, in the works, until the introduction of the Remote control and the TMP36 addition. I shall try to get THAT caught-up as well, and figure-out the best way to attach here.
Thanks again!

Hi,
Good stuff, so you will have to edit/re-write the "case 1" to make it time dependant rather than temperature.
The over-temp needs to be external to the switch.. case.. so it monitors ALL the time in case of contactor failure and sound an alarm.
Possibly a function on its own.
Tom... :slight_smile:

End-of-day, here, and… I never got back on the CAD sketch (yet). After seeing a couple minor things (in the code you provided) that would need to be changed {based on the actual purpose/intent}, I tried several times to EFFECT those changes, and (FYI) here is where I’m at:

Code as it sits on the UNO (with “delays” and yellow led, just so I can SEE each step for now):

//  Code Uploaded successfully, and (So Far) Sort-of-Working , though , peculiarly.
//  A ("controlled") heat source (heat-gun) will be used to verify/validate TMP36 "control"

#include <LiquidCrystal.h> 			// Library needed for LCD display

int tempPin = A0; 					// "Int-Var" for TMP36 sensor pin
int relayPin = 7; 					// "Int-Var" for Relay-Pin [7]
int buttonPin = 8; 					// "Int-Var" for buttonPin INput
int yellowLEDPin = 11; 				// "Int-Var" for Pin 11 - Yellow "cool-off" led
int redLEDPin = 12; 					// Red LED ~ Power is on, but Relay "off"
int greenLEDPin = 13; 				// Green ["Relay-is-On"] LED
int stateRelay = LOW; 				// Default state for Relay ("off")
int stateButton; 					// "Int-Var" "Placeholder/State" for Button
int stayON = 1500; 					// Coil stay on for 1500 ms
int previous = LOW; 					// const int temperaturePin = 0; JUST refer-to AS "A0"
const int rs = 9, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 	// Initialize Arduino -to- the connection-of-the-LCD

float voltage, degC, degF; 				// float = decimal# digits ahead & behind
long time = 0;
boolean hot = false; 					// Test whether cool-down is called-for
long debounce = 50; 					// variable for "stateButton" test


float tempSet = 155.0; 				// Set max Temp for coils (LOW for initial safety/testing)
float cooltempSet = 140.0; 			// Set Cooldown-To temp(*) / “realistic”...
byte processStatus = 0; 				//  0 = idle awaiting input  1 = heater activated (timed 
							        //   sequence)  2 = cooldown period
void setup() {
  pinMode(tempPin, INPUT); 			// TMP36 'sensor' A0
  pinMode(buttonPin, INPUT); 			// buttonPin ; pulled LOW thru resistor, til Remote > "On"
  pinMode(relayPin, OUTPUT); 			// Pin 7 - Relay controlling 500A contactor
  pinMode(yellowLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT); 			// } all 3 LED pins are, obviously, "Outputs"
  pinMode(greenLEDPin, OUTPUT);
  							        // Set-up the initial LED status ("Ready")
  digitalWrite(yellowLEDPin, LOW); 		// Yellow = "System is on-Hold", not ready-to-use YET.
  digitalWrite(redLEDPin, HIGH); 			// Red = "System is Ready" to use , relay is "Off"
  digitalWrite(greenLEDPin, LOW); 		// Green = "System_Firing" || relay is "On" !
  lcd.begin(16, 2); 					// moving "begin" here caused the LCD to start writing
} 							        // an "extra word" "Temperature" after the numeric degrees
							        // printing "F" with extra "spaces" to eliminate that.

void loop() { 						// Everything is in our loop
  if (processStatus == 0) 				// if at idle, check button
  {
    stateButton = digitalRead(buttonPin); 	// Check status of (Remote) button via its relay being used.
    if (stateButton == HIGH)
    {
      processStatus = 1; 				// Operation process activated.
    }
  }
  switch (processStatus)
  {
    case 0: 						         // idle mode
      TempRead();
      TempDisplay();
      digitalWrite(relayPin, LOW);
      digitalWrite(yellowLEDPin, LOW);
      digitalWrite(greenLEDPin, LOW);
      digitalWrite(redLEDPin, HIGH);
      break;

    case 1:  						 // Operating mode
      TempRead();
      TempDisplay();

      if (degF < tempSet)
      {
        digitalWrite(relayPin, HIGH);		// IF temp < 155 ... “energize”...
        digitalWrite(yellowLEDPin, LOW);
        digitalWrite(greenLEDPin, HIGH);	 // and set LEDs accordingly
        digitalWrite(redLEDPin, LOW);
        delay(stayON);					 // Hold “On” for 1500  ms...	
        digitalWrite(relayPin, LOW);		 // ...then...de-energize
        digitalWrite(yellowLEDPin, HIGH);	 // and set LEDs accordingly
        digitalWrite(greenLEDPin, LOW);
        digitalWrite(redLEDPin, LOW);
        delay(1500);                                      // a "default" scant-second wait with Yellow LED
        digitalWrite(yellowLEDPin, LOW);	
        digitalWrite(redLEDPin, HIGH);
        {
        processStatus = 0;
        }
        break;
      }
      else
      {
        processStatus = 2; 				// operating mode complete...
      }
      break;

    case 2: 						        //  'cooling mode'
      TempRead();
      TempDisplay();

      if (degF > cooltempSet)			// re-setting "cooltempSet" > (("realistic"))
      {
        digitalWrite(relayPin, LOW);
        digitalWrite(yellowLEDPin, HIGH);
        digitalWrite(greenLEDPin, LOW);
        digitalWrite(redLEDPin, LOW);
      }
      else
      {
        processStatus = 0; 				// cooling mode complete, go back to idle mode
      }
      break;
  }
}							        // “End” loop


//=== Functions======

void TempRead()
{
  voltage = analogRead(tempPin) * 0.004882814; 	// A0 | converts 0-to-1023 to 0.0-5.0
  degC = (voltage - 0.5) * 100.0; 				// a conversion formula from spec-sheet(reverify)
  degF = degC * (9.0 / 5.0) + 34.0; 				// conversion formula C to F
  return;
}


void TempDisplay()
{
  lcd.setCursor(0, 0);
  lcd.print("Temperature is: "); 			// WRITE-To LCD instructions here
  lcd.setCursor(0, 1);
  lcd.print("      ");  					// to clear the temp reading for the next value.
  lcd.setCursor(0, 1);
  lcd.print(degF);
  lcd.print(" F         "); 				// needed spaces to eliminate a "2nd_printing" of "Temperature" (?)
  return;
}

THE ISSUE that has had me baffled most of the afternoon is the peculiar change in operation (timing/LEDs, as well as the LCD!) depending on whether it is operating SOLELY off the 12vdc power into the UNO “barrel” connector, OR if I also leave the USB plugged in.

Clearly, there are some “Arduino issues” with which I have not yet become familiar!

If it is on 12v power ONLY, the lcd displays “ok”, but, the green led “bounces” (every time), and, the code SKIPS the “default/brief” yellow led displaying.
See video here [I figured-out my error in “Sharing” in Google drive]

THEN, if I leave the USB plugged-in as well…
suddenly, the “timing-&-leds-displaying” is perfect, for where I’d like to be right now.
HOWEVER, the lcd (which displays ok initially), goes absolutely haywire (scrolling chinese? characters) after the relays cycle.
See video here.

Simply FYI, this is my 3rd LCD hooked-up here; 1st and 3rd being 16x2, 2nd was a 20x4. I remain puzzled as to why none of mine display ‘brightly’ like those I see elsewhere. I always have to adjust the pot to get a display at all, but, it never gets better than what I consider “1/2 way there” (brightness).

Any and all suggestions are most appreciated!

Hi,
It looks like a power supply problem, probably a loose or missing gnd.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Not a Fritzy picture please.

Label your components and include your power supply.
What is the spec on your 12V power supply?

Try operating with the relay disconnected.

Tom... :slight_smile:

Your on-board regulator has to drop 7V when powering it with 12V, and with a maximum power dissipation of some 700-800 mW you can't feasibly expect it to handle more than about 100-110 mA before overheating. The Arduino + LED display + other LEDs and you're easily over that number.

[TomGeorge & wvmarle] Thanks guys - I believe y’all just might have hit the proverbial nail…(on-the-head).
I am replacing the sola power supply that I was using with a brand-new (pulled the box out of the closet) PC power supply that was looking for a reason-to-be-used .
See attached image (I hope{?}…the “Preview” doesn’t seem to display it for me).
While disconnecting/soldering/reconnecting everything (giving separate power to the relays, lcd, etc), I shall finish the cad sketch to upload, hopefully by end-of-day.
Thanks again, for the pointers & “confidence-boosting”…(!)

Well, end-of-day here…and, switching power supplies ain’t as easy as a couple websites make it out to be!
Several “Maker / Instructable” type sites ((among others))
state that simply jumpering the (“green”) “PS-ON” wire to a ground (Black) will enable the power supply to come on … (assuming plugged-in and rocker switch on).

The ‘PS-On’ wire of mine is gray, and, even with a couple 5v relays (on reds-&-ground) and a 12v fan (on yellows-&-ground) for a load on the supply, I get absolutely NOTHING!

Needless-to-say … “stuck back at square one” for the time being… (praying that you’ll “stay with me”)

Well, it's now end-of-day Friday --- interruptions/distractions have kept me from (yet) finishing the cad sketch, BUT! ... "for y'alls entertainment"...

  1. The ATX power supply conversion is NOT going to happen. Having gathered plenty of confidence from numerous sites, I have tried "everything under the sun" to get it to "power-on" for me (with loads on both 5v and 12v sides)... all to no avail. Thus, for the sake of a "means to the end", I disassembled another project to provide a PAIR of the SOLA (12v) supplies, AND, I also have a 9v "wall-wort" powering the UNO.

  2. The TMP36 has been "extended" on a 42" piece of fully shielded sensor cable (with 0.1ufd cap & resistor, per spec sheet)...

  3. Code remains "as above", and... although everything else seems to be doing EXACTLY what I wanted to see at this point (see the video just shot, here)... that darned LCD display still (only once-in-awhile) decides to spit-out scrambled/scrolling chinese characters. It waited til after the 5th remote-button-press on the video. It did it the 2nd time, after first firing it up... and it has gone up to 9 cycles most recently. (It always "resets", displaying the temperature properly after the next button-press.)

Can the UNO not handle the green LED and 5v 'duino ("Songle") relay, together with the TPM36 sensor and the 16x2 LCD module...(?)

[ Will get that cad sketch added here when I can... both .dwg and "Arch D" pdf'd!.]

Hi,
Separate your wiring, keep your display wiring away from everything else.
Keep your temp sensor away from power supply leads and the “heater” leads.
Get the relay out from the other wiring.

The rats nest you have, and it happens as you prototype, is probably your major cause of the glitches.

Please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks… Tom… :slight_smile:

Well, it’s been an arduous week (on numerous fronts)… with only a smidgen of headway being made HERE.
I found the “official” (who’d-a-thunk-it!) “Arduino” page on using the 16x2 LCDs, and: therein, it shows a connection that I had NOT had previously! {5v thru a 220-ohm resistor to the “A” terminal.
“Voila”, the display (was) no longer “dull”/“dim”, but blue-bright, like the images I see online.
Well…it was, for a few “clicks” of the remote. Then, the chinese character scrolling started back up, and, back to “dim” again.
Still “readable”, whenever it stops the scrolling nonsense…but “dull”.
Attached is the FINALLY completed cad sketch (including big-pdf’d version).
I trust that it isn’t too ‘discombobulated’ (“go-easy-on-me”; I’m not schooled in producing quality schematics!)
If anything should jump-out at you as being “inappropriate”, circuit-wise (or, in combination WITH the code, up above)… feel free to enlighten me, PLEASE…(!)
Many Thanks ~

Arduino_LCD_Remote_&_Relay(s).pdf (336 KB)

sketch.zip (103 KB)

Arduino_LCD_Remote_&_Relay(s).pdf (336 KB)

While not signed "Fritzing" and it has some pin labelling, the diagram you posted looks the part and is about as unreadable...

... (?)..."unreadable"...? Sorry, "best I can do". The zipped "sketch" is Autocad Lt_13, and the pdf is "ArchD" (plottable / zoomable to 24"x36")... again, "granted", I am not one of THESE GUYS... but, I believe that I have everything "tied" to the correct connect points ("as it sits", so-to-speak).
IF I get to the point of trying to assemble to a perf-board, or 'whatever' for a final assembly, I shall try to better-the-effort.....

Use a schematics CAD software such as KiCAD or EagleCAD, then you can at least use normal electronics symbols instead of renderings of your parts, and it helps keeping the mess of wire connections down. Positive power up, ground down (with some effort I found a +5V but no GND yet in your schematic!), signals run from left to right.