Send to a Friend

XOIIO's avatar

Help with this arduino code.

Asked by XOIIO (18328points) June 22nd, 2013

I have a topic over on the Arduino forums where I am trying to work out how to write an if statement, one person there gave me a rough outline, and it kind of helps but I am stuck in the middle.

If (its been X seconds since the lastTime)
{
set lastTime to Now
set difference to absolute value of thisValue minus lastValue
set derivative equal to difference divided by X
set lastReading to thisReading
check if the deriviative is within a certain threshold and do something based on it
}

I have come up with this so far, however, I don’t know what to do for this line: set derivative equal to difference divided by X

Aside from that I think I have the start out right.

if (currentMillis – previousMillis > interval) {
previousMillis = currentMillis;
delta = celsius – lasttemp;
}

Can anyone lend some advice?

Using Fluther

or

Using Email

Separate multiple emails with commas.
We’ll only use these emails for this message.