Go Down

Topic: Last stage debugging - Help !![SolveD] (Read 3897 times) previous topic - next topic

wildbill

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.

taz3m

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 ..
tz
.....

taz3m

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 . . .
tz
.....

lloyddean

When are you going to fix -

Code: [Select]

if ( FanStatus )
    ;
{
FanControlOFF();
}


lloyddean

#19
Mar 06, 2013, 08:04 pm Last Edit: Mar 06, 2013, 08:06 pm by lloyddean Reason: 1
And didn't you mean -

Code: [Select]

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


wildbill

This section (and others like it) could be improved/shortened:
Code: [Select]

  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: [Select]
 
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.

lloyddean

Amongst other things -

Code: [Select]

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 "));


taz3m

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  :%

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: [Select]

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 . .
tz
.....

lloyddean

'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/>

taz3m

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 . . ;)

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 ...
tz
.....

wildbill

#25
Mar 07, 2013, 06:43 pm Last Edit: Mar 08, 2013, 01:43 pm by wildbill Reason: 1
What I'm suggesting is that the sections like this:
Code: [Select]
  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: [Select]

DisplayStatus("Pump",pump_Status);


Where the DisplayStatus Function is:
Code: [Select]

void DisplayStatus (char* Title,boolean Status)
{
Serial.print(Title);
if(Status)
  Serial.println(" ACTIVE);
else
  Serial.println(" INACTIVE");
}

lloyddean

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/>

taz3m

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 . .



tz
.....

lloyddean

#28
Mar 10, 2013, 07:37 pm Last Edit: Mar 10, 2013, 07:42 pm by lloyddean Reason: 1
I'm curious why this continues to linger in your code -

Code: [Select]

if (FanStatus == true);{
FanControlOFF ();
}


taz3m

Oops was busy adding new lines and forgot about modification.

A small recap please,  ^_^ . .

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: [Select]

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




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

Go Up