Show Posts
Pages: 1 ... 62 63 [64] 65 66 ... 230
946  Using Arduino / Programming Questions / Re: Can't get out of for loop on: July 15, 2013, 05:53:00 pm
But the problem is that once a false value of the variable in inner for loop is reached,
What do you mean by "a false value"? What variable is getting this "false" value.

Code:
         Serial.println("i");
         Serial.println(i, DEC);

Your serial monitor would be much easier to read if you didn't put labels and values on seperate lines. Try something like this:

Code:
Serial.print("i = ");
Serial.println(i, DEC);
947  Using Arduino / Programming Questions / Re: Can't seem to get out of loop. on: July 15, 2013, 05:46:55 pm
It's too bad that you gave up without heading my advice about the erroneous semicolons, or the improper utilization of the equality operator.
948  Using Arduino / Programming Questions / Re: Storing a previous value/creating an array on: July 15, 2013, 05:45:32 pm

Quote
You don't have to, but that would be one way to keep track of the previous values, and that is what you need to do.

Any suggestions on how to do this?

Assuming you have three variables: current, last and former. Right before you set the value of current, set former to last, and last to current.
949  Using Arduino / Programming Questions / Re: Storing a previous value/creating an array on: July 15, 2013, 05:17:42 pm
Do I need to create an array?

You don't have to, but that would be one way to keep track of the previous values, and that is what you need to do.
950  Using Arduino / Project Guidance / Re: Controlling servo motor with arduino on: July 15, 2013, 03:37:39 pm
I would still use a for loop right?

Yes.
951  Using Arduino / Project Guidance / Re: Turning on the light while the RFID tag is in place? on: July 15, 2013, 03:36:33 pm
Perhaps it might be prudent to actually state WHICH rfid reader you are using...
952  Using Arduino / Project Guidance / Re: Can anyone help me on: July 15, 2013, 03:00:01 pm
You can't have multiple setup() and loop() functions. Here's a start:


Code:
int ledPins[] = { 12, 11, 10, 9 };
int vibrationSensorPins[] = { 8, 7, 6, 5 };

void setup()
{
  // TODO: Set the appropriate pins to INPUT/OUTPUT.
}

void loop()
{
  // TODO: Get a random number
  // Turn on an LED
  // Record the time
  // Block until 4 seconds elapsed, or sensor goes off
  // Turn off led
  // wait 4 seconds
}
953  Using Arduino / Programming Questions / Re: Can't seem to get out of loop. on: July 15, 2013, 02:58:04 pm
Code:
relayState == digitalRead(relayPin);

Comparison (==) and assignment (=) are NOT interchangeable.
954  Using Arduino / Programming Questions / Re: Can't seem to get out of loop. on: July 15, 2013, 02:48:18 pm
If the relay is off, using delay(1000), I want to keep track of the number of seconds in Counter1. When Counter1 reaches 60, I want to increment Counter2 and keep track of the minutes. If the relay goes on during this count, I want to then print the number of total "off" minutes in Counter2. Serial.print("Minutes Off "), Serial.println(Counter2).

If the relay is on, using delay(1000), I want to keep track of the number of seconds in Counter3. When Counter3 reaches 60, I want to increment Counter4 and keep track of the minutes. If the relay goes off during this count, I want to then print the number of total "on" minutes in Counter4. Serial.print("Minutes Off "), Serial.println(Counter4).

So in other words, you want to print out how long it has been on or off for every 5 seconds. When it switches from on to off you want to print how long it has been on/off for, in minutes?

God only knows why you are incrementing the "minute" variables (why aren't these variables named seconds and minutes?) after 5 seconds...

Quote
The program prints every second instead of 5 and never prints the total minutes when the relay changes state from off to on or from on to off. If I press the Arduino reset button after the relay turns on or after it turns off, the program starts to keep track of the correct state, and only does if the reset is pressed but still never prints the total minutes for either state.
 Thanks for the help.

The semicolon at the end of the if statement pretty much negates the if statement.
955  Topics / Home Automation and Networked Objects / Re: Arduino and Google Voice on: July 15, 2013, 02:40:02 pm
The question is...is it possible?
Yes

Has anyone ever tried something like that?
No idea, but Google is pretty knowledgeable on those types of questions.

I really don't know how to start, how can i get the string from Google?
By using their API. You'll need a script/program running on the computer. You can probably find a python script or something out there that does this.

Should i use a program or should i write one myself (I have medium knowledge of C / C++) ?
Depends on whether or not there is a program that meets your requirements.
956  Using Arduino / Project Guidance / Re: Can anyone help me on: July 15, 2013, 02:30:20 pm
Post your code.
957  Using Arduino / Programming Questions / Re: Can't seem to get out of loop. on: July 15, 2013, 01:45:15 pm
So now it counts and prints every second instead of every five.

Perhaps you should try to describe what you are trying to accomplish with this code, rather than having us guess. Does this mean you want it to display something like:

Code:
Open 5
Open 10
Open 15

? Because you haven't described what you are trying to do, and with your code, it's anyone's guess.
958  Using Arduino / Programming Questions / Re: Can't seem to get out of loop. on: July 15, 2013, 01:43:02 pm
Code:
if (Counter1 > 5);{

We don't usually put semicolons after if statements...
959  Using Arduino / Programming Questions / Re: Command for auto-off? on: July 15, 2013, 11:38:45 am
So I guess that is a no?

Correct, there is no way for the Arduino to automatically shut itself without the aid of additional circuitry.
960  Using Arduino / Programming Questions / Re: Can't seem to get out of loop. on: July 15, 2013, 11:26:31 am
relayState is never updated within your while loop.

This does absolutely nothing:
Code:
digitalRead(relayPin);

I suspect you meant this:
Code:
relayState = digitalRead(relayPin);
Pages: 1 ... 62 63 [64] 65 66 ... 230