Show Posts
Pages: 1 ... 2248 2249 [2250] 2251 2252 ... 3339
33736  Using Arduino / Programming Questions / Re: Limits on size of String and using indexOf() ? on: November 27, 2011, 07:24:52 pm
It was pointed out that the String class was the source of your problem. You insist on using it anyway. OK, fine, it's your code and you can do what you like with your code.

But, there is no way that I can consider it smart.

People have written extremely complex string (lower case s) manipulation code using the same string handling functions that the String class (upper case S) wraps, without the memory manglement issues that the String class presents.

It is not that difficult to find the source code for the String class and to locate the indexOf() function in the class, to see how the class performs the task of locating the first occurrence of a particular character in an array, if it isn't obvious which string method to use.

The String class should, at best, be a reference, not a tool that actually gets used. At least not for anything more than 10 characters in length.

If you are already storing the character data in a character array, using the String class so you can use the indexOf() function is a crutch.
33737  Using Arduino / Project Guidance / Re: What can an Arduino do in 125us on: November 27, 2011, 07:15:36 pm
If you have a 16MHz oscillator then you can use the pre-scaler to divide by powers of 2 from 1 to 256.
It's probably a lot easier than changing the crystal.
You can't make it faster, though, which is what OP (seems to think he/she) needs.
33738  Using Arduino / Project Guidance / Re: Turn on LED > push button > take and transfer picture on: November 27, 2011, 07:13:26 pm
will send the character 1 to the Arduino.

   if ( == 1) {
which then expects the integer value 1, which is not the same as the character '1'.
byte b = - '0';
if(b == 1)
  // The character '1' arrived...
   if ( == '1') {
33739  Using Arduino / Project Guidance / Re: PTZ controller on: November 27, 2011, 07:03:59 pm
Hey Troll,
If you look at your keyboard you will see that the T and the Y are right next to each other it's called a type-o.
You want your leg back? I had no idea that a gentle tug would rip it clean off.

I've got 3 other forums where I can get less abuse and more answers.
Just out of curiosity, why didn't you go there, then?

Asking you to explain what kind of help you need is hardly abuse. Asking you what code you have (none is a perfectly reasonable answer) is hardly abuse.
33740  Topics / Robotics / Re: Reading from Serial on: November 27, 2011, 06:42:28 pm
It HAS to be something in my code.
Possibly. But, for code that determines whether the Arduino can send data, or receive data, that code is WAY to complex.

Try something much simpler that blinks an LED when data is received, and sends that data back out.

Until what comes in makes sense, developing complex code to use that data doesn't make sense.

Unplug the motors, and put them back in the box. Remove all code for manipulating the motors.

Get rid of unused functions.

     inByte =;
Is the Arduino supposed to be clairvoyant? Print a character, then read it.

    for (serialLoop=0; serialLoop < 16 && Serial.available(); serialLoop++) {
What is the significance of looping 16 times?

         case 119: //w - forward, pin 6+8
Why not:
case 'w': // No comment needed
33741  Using Arduino / Programming Questions / Re: Multidimensional Arrays with Pointers on: November 27, 2011, 06:30:05 pm
A 2D array is an array of arrays. To copy to a specific element in the array, you really are not concerned about the 2nd dimension of the array.

char someStuff[10][64]; // An array of 10 strings of length 64
strcpy(someStuff[4], "here is some text); // put some text in string 4

in my case str2 is a 2D array so needs to be referenced as such:
strcpy(arrayOfStrings[0][],"hello")  which throws up an error.
As well it should. See above.

Also, how do I pass arrayOfStrings into the function?
Two possibilities.
void fun1(char arr[MAXCOMMANDS][]) {}
void fun2(char **arr) {}
33742  Using Arduino / Programming Questions / Re: Code to store data in EEPROM with Xbee on: November 27, 2011, 06:22:10 pm
    for(addr = 0; addr <= 512; addr++) {;
      Serial.print(sensorValue, DEC); 
      addr = addr + 1;
      delay(10000); //read values once every 10seconds
Why are you incrementing addr inside the loop, too?

The 512 places in EEPROM are numbered 0 to 511. You should lose the = after the <.
33743  Using Arduino / Project Guidance / Re: Help adding a dynamic HTML buttom from Arduino Web Server. on: November 27, 2011, 06:14:08 pm
Let me try to clarify my position a bit. An Arduino as a server can serve up a page containing a jpeg image, if you wanted to do that. Now, suppose that you did that, and that the page had a test field, a file locator button, and a submit button, that allowed you to upload a different picture back to the Arduino.

What would you expect the Arduino to do with that picture?

If the Arduino serves up a page that contains buttons, to turn some pins off or on, and a submit button (or the on/off buttons are submit buttons), it is quite reasonable to expect the Arduino to be able to parse the returned data an do something with it.

The Arduino can serve up a page that contains an embedded swf file (a Flash file). It is not able to understand the contents of that data stream, so sending a page back to the Arduino that contains a .swf file is not something that makes sense.

like 90% of all web pages out there
I'm 100% certain you made that number up. I don't believe that Flash is anywhere near that prevalent.
33744  Using Arduino / Project Guidance / Re: Standalone web client on: November 27, 2011, 06:04:44 pm
I  have seen others mention using additional storage space..

does 'solve' the memory space?  or not? if the page is still big.. the Arduino still wont be able to 'serve' it up....right?  even it is residing on an SD card or something?
Yes, putting all or most of a static page on a SD card works. The thing is, though, that static pages are boring and useless. Dynamic pages, where the user can make the Arduino do something, or can get real-time information from the Arduino is what makes for interesting pages. Don't confuse interesting with big.
33745  Using Arduino / Project Guidance / Re: Standalone web client on: November 27, 2011, 06:01:55 pm
If the Arduino is a web server, GET requests are shown in plain text in the data that the Arduino receives. It is easy to locate the record containing the GET request, and to parse that record when it is complete.

Performing action, then, is trivial.

If the Arduino is a client, it makes GET requests, and the server prepares a response. After a bunch of headers comes a blank line, followed by the data output by the servo script that the GET request asked to run.

Locating the response, and parsing it is straight-forward. Performing action is trivial.

I am interested in learning more about the Arduino AS the server first though..and seeing what its limitations on the memory is..etc
Take it in steps. First, have the Arduino read the client connection, and serve up a simple page.

Then, have the Arduino serve up a form. Add a submit button (or two or three) to the form. Simply read what the client request looks like, for both the initial GET request and the modified request made when the submit button(s) is/are pressed.

Then, parse the request, and perform any required actions.
33746  Using Arduino / Project Guidance / Re: PTZ controller on: November 27, 2011, 05:51:04 pm
Ant help would be appreciated.
What kind of help does your ant need?

All that you are said is that you are trying to do something. No code. No explanation of what worked or what didn't work.
33747  Topics / Robotics / Re: Reading from Serial on: November 27, 2011, 05:46:11 pm
A couple of comments.
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
SoftwareSerial is obsolete. NewSoftSerial is a much better replacement.

  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
You told the SoftwareSerial instance that these were its pins. What are you messing with them?

33748  Using Arduino / Programming Questions / Re: Maximum number of cases in switch? on: November 27, 2011, 05:26:51 pm
Once you know that one or two cases are invoked correctly, it is reasonable to assume that the rest of them will be, too.

So, the Serial.print() statements, which use up a lot of SRAM are not really needed, are they? If you still think that they are, make them as short as possible. "Sending 1..." really doesn't convey any more information than "1", but consumes 12 times as much SRAM.
33749  Using Arduino / Programming Questions / Re: Reading serial data and moving servo on: November 27, 2011, 05:22:36 pm
ah. what is the command line for writing to port?
Gee, do you suppose it might be port.write()?

Or should I change the processing code?
Well, let's think about that for a minute. It doesn't work, which doesn't suit your needs. So, you could either fix it or leave it as is. Let me think about that for a while, and get back to you later.
33750  Using Arduino / Programming Questions / Re: Multidimensional Arrays with Pointers on: November 27, 2011, 05:18:01 pm
The compiler is telling you exactly what the problem is. There is a function, Input::parseRhsLhs, with a specific set of arguments defined. You are not calling it with arguments of that type.

is wrong. Get rid of the * in that statement.

Randomly stuffing & in to get the compiler to quit complaining is not the thing to do. aCommands is defined to be a pointer to a block of characters, not a pointer to an array of blocks of characters. You are trying to treat it as an array of arrays, when it is not that.

You can't copy an array of characters into a single character, which is what aCommands[field_] is.

If you are going to call parse with a 2D array, why is it not defined to take a 2D array?

Pages: 1 ... 2248 2249 [2250] 2251 2252 ... 3339