Go Down

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

taz3m

ok .. i do get it ..

in anyhow, how would i remove this damm bug which is preventing my voltage from flipping..

im trying all combination since then, but any of them is  not working..

do you think that the voltage flipping which is under case 0, is being missed or anything likewise..  i wanna try to put that on a different case say case 1 . .

thansks for any sugestion . ..

taz..
tz
.....

PaulS

You've made some code changes, hopefully. Now, you need to post the current code.

PeterH


soil moisture sensor ... pin 13


I haven't looked at your code at all, but this comment above caught my eye. If you are implementing a resistive moisture sensor then you will probably be trying to set up a voltage divider with some high resistances. In that case, the integral LED that most Arduinos have connected to pin13 might be acting as a pull-down which prevents your circuit from dividing the voltage correctly. You could try using any pin other than 13; if that then works correctly it suggests this was the problem.
I only provide help via the forum - please do not contact me for private consultancy.

taz3m

hello . .

Been working a bit with the code. .

Quote

I haven't looked at your code at all, but this comment above caught my eye. If you are implementing a resistive moisture sensor then you will probably be trying to set up a voltage divider with some high resistances. In that case, the integral LED that most Arduinos have connected to pin13 might be acting as a pull-down which prevents your circuit from dividing the voltage correctly. You could try using any pin other than 13; if that then works correctly it suggests this was the problem.


I agree with you that the pull down resistor willbe adding up in the voltage divider circuit, even though changing the pin from 13 to 8 still results in my voltage not flipping. however, i did observed some more stable values.

I bring some changes here with the code, but still stick to my bug :


Code: [Select]

// Function to run water pump on conditions of soil moisture

if (FuncActive == true){
  if (pump_Status == false){
pumpControlON ();
  }
}

// Function to run off pump based on conditions
if ( pump_Status == true){
pumpControlOFF();
}

// Function to Activate LightSwitch for plants on conditions of ambient light
if (ReadPhoto == true){
LightAction ();
}
// Function in taking Temperature Readings and saving to global variable Actualtemp
if (TempRead == true){
Actualtemp = temperatureRead ();
TempRead = false;
}


i think i will be changing the switch case variable, the itemIdx from incrementing directly as a parameter function, rather incrementing it through each case, any suggestion towards that approach.

Thanks
tz
.....

PeterH

I tried to post this earlier but the site seems to have junked my reply - sorry if you end up with two copies.

Look here:

Code: [Select]

if( currentTimer >= (timerLast + timerRate) ){
  timerLast = currentTimer;
switch(++itemIdx){


Firstly, that's not a very good way to compare the times because it doesn't cope with timer overflow.

You would be better changing the code to this:

Code: [Select]


if(millis() - timerLast >= timerRate)
{
 timerLast += timerRate;
 // ...


That's not going to stop your sketch from blinking, though. I suspect the reason for that is here:

Code: [Select]

switch(++itemIdx){


This increments itemIdx but does not wrap back from five to zero. It would be better to do it like this:

Code: [Select]

const int NUM_ITEMS = 6;
itemIdx = (itemIdx + 1) % NUM_ITEMS;
switch(itemIdx)
{
 ...

I only provide help via the forum - please do not contact me for private consultancy.

Go Up