Show Posts
Pages: 1 2 [3] 4 5 ... 67
31  Using Arduino / Programming Questions / Re: How to make global variables accessible to libraries/classes? on: May 10, 2013, 06:57:45 am
Code:
since the Arduino IDE doesn't allow me to define classes in the sketch
Now I am puzzled.  What gave you this idea?  The IDE doesn't enforce syntax, and the compiler is a C++ compiler.

It would help to understand the current organization of the code a little better.  Where are the globals declared in your big pile of code?  And where are they defined?

Can you post the code, piecemeal if needed, in code tags, please?

-br


32  Using Arduino / Programming Questions / Re: Variable scope and RAM on: May 09, 2013, 08:16:22 pm
Yes, because C locals live on the stack.

Once the procedure defining a local variable returns, the location on the stack reserved for that local is released with the rest of the stack frame to become free stack space (or more properly free space between the stack and the malloc heap).

-br
33  Using Arduino / Programming Questions / Re: How to reset the values in a char pointer array on: May 09, 2013, 07:07:27 pm
Quote
it won't run the rest of the code to save the file, like it does the first time you run it
Quote
So, what happens instead? 

You need to go on the attack and instrument your program to tell you where it's screwing up.  Sprinkle Serial.print() statements near where you think it's leaving the tracks.  Log a word to say where you are, or an important value.  Soon you will find some output that is not what you expect, something wrong the second time.  It will lead you to your bug.

It may not be doing the right thing the second time around, but it is doing something.  Figure out what that wrong thing is, and you'll be on the way to making it work.

Good luck with your project.

-br

PS: It wouldn't hurt to re-terminate your input arrays every time you add a a character to them.
34  Using Arduino / Programming Questions / Re: How to reset the values in a char pointer array on: May 09, 2013, 06:56:06 pm
Quote
the problem is when you run through it again it doesn't work
What does "it doesn't work" mean?  What does it do that you don't expect, or not do that you do expect, when you clear the arrays using memset or setting the zeroeth element to zero?

"It doesn't work" is the world's worst bug report, because it tells us nothing.

-br
35  Using Arduino / Programming Questions / Re: How to reset the values in a char pointer array on: May 09, 2013, 06:47:26 pm
This is a very creative way to terminate a char array:
Code:
   strcpy(money+money_index, ""); //converts to pointer array
But this would work the same and generate less object code:
Code:
   money[money_index] = 0;

Could you state your problem description more clearly, please?  What are you trying to accomplish, and what seems to be going wrong?

-br
 
36  Using Arduino / Programming Questions / Re: How to reset the values in a char pointer array on: May 09, 2013, 06:28:39 pm
If you're really using the array as a C string, you can simply set the first element to zero.

But, as guix says, memset should have worked.


-br
37  Using Arduino / Programming Questions / Re: does not name a type error....Urgent help needed on: May 09, 2013, 02:44:11 pm
And the library shows up properly in the File -> Examples menu?

And the examples for the library - do they compile?

-br
38  Using Arduino / Programming Questions / Re: does not name a type error....Urgent help needed on: May 09, 2013, 02:20:13 pm
Did you restart the Arduino application so it knows about the new libraries?

Check the File-> Examples menu.  Is the library there?

-br
39  Using Arduino / Networking, Protocols, and Devices / Re: PHP data transfer with official Wifi shield on: May 09, 2013, 10:23:18 am
You removed the Host: header, which is probably needed, and changed the HTTP/1.1 to HTTP/1.0, which won't help.

Whenever you have a problem like this the first thing to do is to check the error and access logs to see what's really being received by the server.  That would be a good place to start, after making the two fixes above.

-br
40  Using Arduino / Programming Questions / Re: Changing variable in loop on: May 09, 2013, 09:51:36 am
Where in the code did you tell it to change the LED?

-br
41  Using Arduino / General Electronics / Re: Arduino Powers on With Power Applied to Input Pin on: May 09, 2013, 06:37:53 am
Quote
I have all of the inputs running through 7805 voltage regulators to bring the power down to 5V.
This is quite creative, but it guarantees the inputs will have all the power you need to cook your arduino. 

Have you considered a more conventional approach to conditioning the inputs like opto-isolation or even a resistor divider?

-br
42  Using Arduino / Networking, Protocols, and Devices / Re: PHP data transfer with official Wifi shield on: May 08, 2013, 08:32:18 pm
I think I see a bug that may account for the problem you're seeing.

It's this same line of code:
Code:
  String url = "http://my_website.com/update.php?ID=1&DATA=0";

The url that is sent in a get request is not supposed to include the http://mywebsite.com part.  Just the url relative to the server.  So, this might work better for you, and fix the String / char* thing at the same time:
Code:
  char *url = "/update.php?ID=1&DATA=0";

I wouldn't be surprised if you were getting an error in your error log before, and I bet this change would help.

-br
43  Using Arduino / Networking, Protocols, and Devices / Re: PHP data transfer with official Wifi shield on: May 08, 2013, 07:57:34 pm
Then wait a little longer.  Your timeout should be on the order of 30 seconds.  It can easily take several seconds for your reply to start coming back.

See waitForInput at line 127 here: https://github.com/billroy/socket.io-arduino-client/blob/master/SocketIOClient.cpp

-br

Edit: Another thing to check: what do the access and error logs on the server say when your sketch sends the GET request?
44  Using Arduino / Networking, Protocols, and Devices / Re: PHP data transfer with official Wifi shield on: May 08, 2013, 07:43:52 pm
You've already confirmed the script works, so echo must be okay:
Quote
it shows up fine when I access the script from my browser

Quote
Is the arduino looking for any kind of a header on the returned data

Not until you write some code that says client.read().  There is no magic.  You have to read every character of the response, starting with the headers.

-br

Edit: It might be worthwhile to check out the ethernet webclient example…
45  Using Arduino / Storage / Re: Converting a float to a char* for writing to SD card on: May 08, 2013, 06:29:22 pm
http://dereenigne.org/arduino/arduino-float-to-string

-br
Pages: 1 2 [3] 4 5 ... 67