Pages: 1 [2] 3 4   Go Down
Author Topic: Last stage debugging - Help !![SolveD]  (Read 3488 times)
0 Members and 1 Guest are viewing this topic.
New Jersey
Offline Offline
Faraday Member
**
Karma: 70
Posts: 3727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Whatever you do though, once you've made any of the suggested changes, please post the entire sketch that's giving you problems - attach it if necessary rather than posting it inline.
Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi peter ..
thanks for your kind response, i appreciate it loads..

i did read about the stack memory being overflow after around 50 days, but did not really know how to aproach for its preventive measures .. here you showed to me..

i was suspecting the itemIdx being my culprit the way it was incrementing.. thanks for confirming ..

i shall try out these changes once im back home, n will update all here with the entire code as attachment as requested by wildbill also ..

thanks again..

see ya ..
Logged


tz
.....

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Thanks for the great help peterH . .

Now my voltage pin do flip like a charm, my moisture values are quite stable and im happy that my sensors work as expected.

The modulo function do great in the switching of the case, great idea . . thanks load peterH.

I attached the source code for reference, and if any other changes and improvements can be made, i will be glad to review it and make necessary changes, while getting to learn more and new things at the same time.

Thanks again for all the responses towards this post.

My next step is to implement an LCD , to display all the real values and essential information with a pushbutton to change the mode Display.
Im looking forward to be using another switch Case function again, hope i dont run into much trouble.

However, troubles are here for us to learn more , . . . and Learning never ends . . .

Regards

Tazlim . . .

* GreenHouse_Rev_F_02.ino (7.37 KB - downloaded 13 times.)
Logged


tz
.....

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When are you going to fix -

Code:
if ( FanStatus )
    ;
{
FanControlOFF();
}
Logged

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And didn't you mean -

Code:
   if ( ! FanStatus )
    {
        FanControlON();
    }
    else
    {
        FanControlOFF();
    }
« Last Edit: March 06, 2013, 02:06:01 pm by lloyddean » Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 70
Posts: 3727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This section (and others like it) could be improved/shortened:
Code:
  if (pump_Status == true)
    {
      Serial.print(" Pump Status : ACTIVE ");
      Serial.println();
    }

  else if (pump_Status == false)
    {
      Serial.print(" Pump Staus : INACTIVE ");
      Serial.println();
    }

If you're testing a boolean, you can simply use
Code:
 
if (pump_Status)
Since it's a boolean, if it's not true, no need to test if it's false.

You have some very repetetive code there. Consider adding a function that takes a boolean and a string. Let the function print the string, test the boolean,  and println "active" or "inactive" depending on its value. Then use if for all that conditional printing you're doing.
Logged

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Amongst other things -

Code:
Serial.print(" Pump Status : ");    Serial.println((pump_Status ? "ACTIVE " : "INACTIVE "));
Serial.print(" Light Status : ");   Serial.println((LightStatus ? "ACTIVE " : "INACTIVE "));
Serial.print(" Fan Status : ");     Serial.println((FanStatus ? "ACTIVE " : "INACTIVE "));
Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello!

Thanks for the suggestions..

Ok i did get it, i will work to shortened and remove some repetitive codes further up, but will have to do some more reading what i see  smiley-draw

The serial print for now is just to test if code is running properly, however i will be using LCD.print to display all these stuffs which is in serial.print for now.

Quote

Code:
Serial.print(" Pump Status : ");    Serial.println((pump_Status ? "ACTIVE " : "INACTIVE "));
Serial.print(" Light Status : ");   Serial.println((LightStatus ? "ACTIVE " : "INACTIVE "));
Serial.print(" Fan Status : ");     Serial.println((FanStatus ? "ACTIVE " : "INACTIVE "));


One question here, how will the code know that if pump_Status is 'true' to display ACTIVE or INACTIVE . .

thanks
taz . .
Logged


tz
.....

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

'false' is always zero, not false is alway not 'zero' yet not 'exactly' 'true' while 'true' is only 'true'.

To answer the question read -

<http://www.cplusplus.com/articles/1AUq5Di1/>
Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You have some very repetetive code there. Consider adding a function that takes a boolean and a string. Let the function print the string, test the boolean,  and println "active" or "inactive" depending on its value. Then use if for all that conditional printing you're doing.

Thats seems interesting, i will try to do this . . any help or source where i can start to grasp a good comprehension about the subject. I think i will be starting with Arduino Reference for string in the meanwhile . .

Thanks . .

Quote

'false' is always zero, not false is alway not 'zero' yet not 'exactly' 'true' while 'true' is only 'true'.


Seems confusing, but i shall read it for a proper understanding, i shall keep things posted here, and in time of trouble, i shall ask for a push from time to time . . smiley-wink

I am actually editing my code for implementation with a 16X2 lcd, and display all my serial print to the latter.

Thanks for your precious time and support . .

See ya ..

taz ...
Logged


tz
.....

New Jersey
Offline Offline
Faraday Member
**
Karma: 70
Posts: 3727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What I'm suggesting is that the sections like this:
Code:
  if (pump_Status == true)
    {
      Serial.print(" Pump Status : ACTIVE ");
      Serial.println();
    }

  else if (pump_Status == false)
    {
      Serial.print(" Pump Staus : INACTIVE ");
      Serial.println();
    }

Could be replaced by a call like this:
Code:
DisplayStatus("Pump",pump_Status);

Where the DisplayStatus Function is:
Code:
void DisplayStatus (char* Title,boolean Status)
{
Serial.print(Title);
if(Status)
  Serial.println(" ACTIVE);
else
  Serial.println(" INACTIVE");
}
« Last Edit: March 08, 2013, 07:43:10 am by wildbill » Logged

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's simple really.  Conditional tests such as used in 'if', 'while', 'do while', and several others, evaluate to zero as false and not zero as not false.

The 'bool' values 'false' and 'true' have specific values - 'false' is always zero while 'true' may be any non-zero value depending upon the language version.

Here is an easy to read article concerning conditionals in C++

<http://www.cplusplus.com/forum/articles/3483/>
Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Im back again after some workings on the code.

I added up from the previous revision, an lcd 16x2, with some new lines in the code, but here im stuck with some bugs in the code.

My temperature part of the code is not giving me values. I suspected some wiring went wrong, however, when i test the temperature code alone, it works as nice as it should be. . .

With this new revision i added the lcd, and some menu to be displayed like, intro menu, soile percentage menu and LDR Raw reading. . I went through a pushbutton to swap between menus.

Here also without pressing my button, the lcd is changing menu.

Find herewith attached my code. Any suggestions where i can tackle for this bug.

Thanks in advance . .

 


* GreenHouse_Rev_F_03.ino (10.29 KB - downloaded 14 times.)
Logged


tz
.....

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm curious why this continues to linger in your code -

Code:
if (FanStatus == true);{
FanControlOFF ();
}
« Last Edit: March 10, 2013, 01:42:02 pm by lloyddean » Logged

Mauritius
Offline Offline
Jr. Member
**
Karma: 2
Posts: 95
Learning Never Ends . . .
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops was busy adding new lines and forgot about modification.

A small recap please,  smiley-kitty . .

I need not to test for a boolean if it is true or not right ?

intead of above i should i be using something likewise :

Quote from: lloyddean
And didn't you mean -

Code:
    if ( ! FanStatus )
    {
        FanControlON();
    }
    else
    {
        FanControlOFF();
    }


Im getting to it, now smiley-sweat .. thanks again . . 
Logged


tz
.....

Pages: 1 [2] 3 4   Go Up
Jump to: