Show Posts
Pages: 1 ... 59 60 [61] 62 63 ... 209
901  Using Arduino / Programming Questions / Re: How can I stop the void loop function? on: June 21, 2013, 12:39:02 pm
while(boolean=true)

What? Why?
902  Using Arduino / Programming Questions / Re: Suggestions for Serial Buffer on: June 21, 2013, 12:38:18 pm
I couldn't get it working even with the delimiter approach.

The code you posted shows no attempt at doing so.
903  Using Arduino / Programming Questions / Re: How would I make this if statement? (if somehting is within x amount?) on: June 21, 2013, 12:36:37 pm
well, that sounds good, but difficult to figure out :/


It's actually not that difficult:

Code:
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
}
904  Using Arduino / Programming Questions / Re: How can I stop the void loop function? on: June 21, 2013, 12:05:20 pm
There is no such thing as a 'void loop' function. There is a loop function, and its return type is void. They're called "banks", not "cash banks."
905  Using Arduino / Programming Questions / Re: How would I make this if statement? (if somehting is within x amount?) on: June 21, 2013, 12:04:18 pm
Also when it is climbing the light stays on which makes no sense, unless there's a problem when it's checking if the temperature is within + / - .10

Because you're missing an important statement in the code copied from the blink without delay example. Without said statement, you're not doing things in intervals, you're implementing a time delay.
906  Using Arduino / Programming Questions / Re: How would I make this if statement? (if somehting is within x amount?) on: June 21, 2013, 12:03:06 pm
By sampling the previous temperature at a different rate than the current temperature, you're making time a variable. Previously, time was a variable, but it took relatively the same amount of time for the loop to complete, so the variable time could be neglected.

This if statement:
Code:
if ( (celsius >= lasttemp - 00.10) && (celsius <= lasttemp + 00.10)
does not take into account how long it has been since lasttemp was sampled. If you want to calculate the derivative, you need to take into account time. The easiest way to do this, would be to every X amount of time, calculate the difference in temperature and call it delta. delta divided by X seconds will give you the rate of change (derivative). If its under a certain amount, then its stable.
907  Using Arduino / Programming Questions / Re: How would I make this if statement? (if somehting is within x amount?) on: June 21, 2013, 11:42:32 am
then they would sync up.

Who would? Avoid using pronouns when describing issues.
908  Using Arduino / Programming Questions / Re: How would I make this if statement? (if somehting is within x amount?) on: June 21, 2013, 11:39:09 am
Would do you mean by "put the same delay on the temperature"?
909  Using Arduino / Programming Questions / Re: Suggestions for Serial Buffer on: June 21, 2013, 11:19:03 am
but I can't not have a delay or else the reads get messed up when sending multiple messages.

It sounds like you might want to use time as the deliminator. Instead of delaying for an arbitrary amount of time, keep track of the time that you last received a character:

Code:
static unsigned long lastReceivedTime = 0;
static boolean receivingMsg = false;
if (Serial.available() > 0)
{
  char inByte = Serial.read();
  lastReceivedTime = millis();
  receivingMsg = true;
  // store the data in the buffer
}

Then, outside of any other conditions, and run as often as possible (no delay() calls), check how long it has been since you last received a character:

Code:
if (millis() - lastReceivedTime > someSetTimeoutPeriod)
{
  receivingMsg = false;
  // process the array and clear the buffer
}

You'll have to structure your loop() function to work more towards parallelism than sequentialism ( I don't care if that's not a word, firefox). To accomplish that, you can't think of what you want to do as a sequence of events, rather, as a collection of events that run independently and are flagged or signaled by each other.

910  Using Arduino / Project Guidance / Re: Automated Lights - Serious battery drainage - need a solution on: June 21, 2013, 11:09:40 am
I simply want to connect an adapter to the mains and control the light with a relay. The relay on the main that goes to the light fixture is already done and functioning but I am powering the arduino with a DC adapter that is less than attractive. I am just asking if there is a way to access the main without affecting the light fixture, given I have the wiring for a one way switch.  

In order to do that, you would need to wire the device in parallel with the light (although you're still affecting it, it's not at noticeable) Given that there is no neutral wire available in your light switch box, you cannot wire it in parallel.
911  Using Arduino / Project Guidance / Re: Dual Shift Register Help Please on: June 21, 2013, 11:07:17 am
Anatomy of your array Given that "!2100":

Code:
inData = "!2100"
inData + 1 = "2100"
inData + 2 = "100"
inData + 3 = "00"
inData + 4 = "0"
inData + 5 = ""
912  Using Arduino / Project Guidance / Re: Automated Lights - Serious battery drainage - need a solution on: June 21, 2013, 11:04:43 am
It's the questioning and answering or reasoning that determines the physical outcome!

Hence the question, "Do you not have the normal Hot, Nuetral and Ground wires going to your switches and outlets?"
913  Using Arduino / Project Guidance / Re: Automated Lights - Serious battery drainage - need a solution on: June 21, 2013, 10:38:44 am
There is no mention of the user wiring anything to the mains

Except for in his first post:

Quote
The main focus of the devices is that they can replace any existing home's outlets and wall switches.
914  Using Arduino / Programming Questions / Re: How to make one variable out of more on: June 21, 2013, 10:37:01 am
But what does the [8] in
Code:
Serial.print(Str1[8], HEX);
mean? I didn't find any explanations.

Google "Arrays"
915  Using Arduino / Programming Questions / Re: How would I make this if statement? (if somehting is within x amount?) on: June 21, 2013, 10:36:14 am
but I want to compare the temperatures between the last 30 seconds, that would make sure it has normalized

The Blink Without Delay example demonstrates on how to perform periodic actions (such as comparing values 30 seconds apart) without blocking the rest of your code.
Pages: 1 ... 59 60 [61] 62 63 ... 209