Show Posts
Pages: 1 ... 2262 2263 [2264] 2265 2266 ... 3067
33946  Using Arduino / Programming Questions / Re: Need help splitting string into array on: June 24, 2011, 06:42:21 am
Quote
In Arduino, "string" is char*.
In C a "string" is a name. not a type. It refers to a NULL terminated array of characters (char {}). One can create a pointer to point to (the first position of) that array (char *).
33947  Using Arduino / Programming Questions / Re: Handling Returned Data from web server on: June 24, 2011, 06:37:32 am
Quote
At some point you gotta just dig in, read the tutorials, read the docs, and read auxiliary articles pertaining to your issue. If your issue is that you don't know how to program in C/C++, read beginners C/C++ articles.
At some point, you have to understand that you can not destroy the hardware by loading a sketch on it and trying to run it. Personal observation is much more useful than asking questions like that last one on the forum.
33948  Using Arduino / Programming Questions / Re: L Led Flashes Constantly on: June 24, 2011, 06:34:39 am
Along with that message, there is a link to the Troubleshooting section. Complain on the forum, in the wrong section. is way down at the bottom of the list. You are supposed to try the steps in order.
33949  Using Arduino / Storage / Re: Need a little help with the new SdFat beta on: June 23, 2011, 09:43:42 pm
Quote
SdFile::exists() searches the instance, which must be an open directory
So an SdFile instance is a directory. Well, that's certainly a good choice of class names. Or, I am missing something.
33950  Using Arduino / Project Guidance / Re: Processing and Minim with some pre recorded sound - and Arduino sensors on: June 23, 2011, 09:15:05 pm
PIR sensors sound like what you want.
http://www.sparkfun.com/products/8630
33951  Using Arduino / Project Guidance / Re: pulseIn, map(), and tone() interfere? on: June 23, 2011, 09:05:47 pm
Code:
  freq = map(average, 320, 520, 100, 1000);  //Remap to a range for the speaker
Quote
As it is right now the serial reads average as ~30, and freq at about -600     
The map function generally is easier to understand when the value to be mapped is in the from range. 30 is not, so getting a value out that is in the to range is impossible.

Perhaps you could explain your choice of ranges.

Of course, calling the tone function with a negative value is not advised.
33952  Using Arduino / Storage / Re: Need a little help with the new SdFat beta on: June 23, 2011, 08:55:16 pm
Since exists() is a member of the SDFile class, it seems strange that it is not a static method, since it does absolutely nothing with/to/about the instance that needs to be created to use the function.

Comments?
33953  Using Arduino / Programming Questions / Re: Interupting and restarting loop on: June 23, 2011, 07:24:02 pm
Quote
But if I cant get the array to start with a button press i am dead before i get started.  Any help will be appreciated. 
Break the problem up into smaller pieces. Write a sketch that reliably reads the state of a switch - pressed or not pressed. If you can't, it's likely a hardware issue.

If you can, then add to that sketch, lighting some LEDs, using the blink without delay example to create a state machine. You have one state where one LED is on, and another state where 3 LEDs are on, for instance. Initially, transition from one state to another when the switch is pressed.

Then, expand that to transition from one state to another (having three or more states makes this easier to see that it works) every 10 seconds (for instance) and restarts at the first state when the switch is pressed.

If you get all this working, then the project you want to accomplish will be a minor extension of what you already have working.
33954  Topics / Robotics / Re: Map Generation on: June 23, 2011, 07:17:14 pm
Quote
The map is a 2D in programming terminology but if you think about in term of vector calculus, it's just a 2D (discrete) scalar field. Where:
f(i,j,P(i,j)) where P(i,j) is the priority of a certain cell (i,j).
If you have a function with 3 variables - i, j, and P(i.j), the function must represent something. It isn't clear to me just what that function represents. Typically, one would say that y = f(x) or w = f(x,y), where y is a function of x or w is a function of y and y. What replaces the ? in
Code:
? = f(i, j, P(i,j))

What do the values in the map shown mean? How will you replace those values that are all over the place with 0 or 1 and retain the same meaning?
33955  Community / Products and Services / Re: Atlas scientific ph/orp stamp RS232 on: June 23, 2011, 07:08:23 pm
Code:
    for(i=0; i <= holding;i++){       //we make a loop that will read each byte we received
If you got 4 characters, holding will contain 4. You loop while i=0, i=1, i=2, i=3 and i=4, to read 5 of the available 4 characters.

The data sheet for the sensor says:
Quote
The output is (up to five) ASCII digits representing the PH and ending
with a carriage return (ASCII 13).
Example:
4.60<CR>
So, you should be reading data until the <CR> arrives, not just whatever happens to have arrived at any given moment.
33956  Using Arduino / Programming Questions / Re: Interupting and restarting loop on: June 23, 2011, 06:18:57 pm
Quote
Why doesnt this work!!!!?
Well, that doesn't surprise me. The loop function is missing the closing curly brace.

It would be helpful when you posted code if you explained what the problem is. There is a big difference between "This code does not work the way I intended" and "This crap code won't even compile". Providing the right description would allow us to focus on your problem, instead of guessing what "this doesn't work" means.
33957  Community / Products and Services / Re: Atlas scientific ph/orp stamp RS232 on: June 23, 2011, 06:14:22 pm
Code:
    for(i=1; i <= holding;i++){                    //we make a loop that will read each byte we received
Array indexes start at 0. Why don't you?

Code:
    for(i=1; i <= holding;i++){                  //we now loop through the array       
    Serial.print(stamp_data[i]);             //printing each byte we received  through the hardware UART
       }

       Serial.println("")
If you started in position 0, you could replace all this with
Code:
Serial.println(stamp_data);

Code:
    mySerial.flush(); 
This was NOT per my suggestion. In fact I strongly encouraged you to get rid of it.
33958  Using Arduino / Programming Questions / Re: Interupting and restarting loop on: June 23, 2011, 06:06:52 pm
Could be a hardware issue. How is the switch wired? You are not using the internal pull-up resistor, so an external resistor is implied. The fact that you expect the switch to read HIGH when pressed implies a pull-down resistor. You do have a pull-down resistor, right?

33959  Using Arduino / Networking, Protocols, and Devices / Re: SMS Phone on: June 23, 2011, 05:56:48 pm
Code:
  if (startup == 0) { SendText("Arduino Re-booting."); startup = 1; }     // if startup = 0 we have booted. Send a text
Multiple statements on one line are hard to read. Why are you not doing this one-time-only operation in setup()?

Code:
boolean Check4Text()                                                      // Here we see if there is a text waiting
{
  delay(10);
Why is this delay here?

Code:
    int Numm=int(rx[loopcount-1]);                                        // Gets message number
After reading random amounts of text, how can you be certain that the message number is in the last character read?

Code:
      Phone_Serial.flush();                                               // Clear the serial store
You don't get to this statement until the while loop ends, and all data that was pending was read. Aside from copying the array of characters that was read into a String object, very few machine instructions have been executed, at the rate of 16000000 per second. How much data do you suppose has arrived in that time? In any case, why do you want to throw any of it away?

Code:
      int loopcount = 0; rx[0] = 0;                                       // init variables
Useful comment, huh? In loop(), you now have two different variables named loopcount. Why?

Code:
      while(Phone_Serial.available() > 0)                                 // loop to get characters in the serial buffer
      {
        rx[loopcount] = Phone_Serial.read();                              // Put recieved chars into the array
        loopcount ++;                                                     // increment counter
      }
      Phone_Serial.flush();                                               // Clear the buffers
As soon as you have read the last character, throw away any unread characters. Again, why?

Code:
void ParseText(char parse[])                                              // Now have the hard bit, stripping data
{
  String Text_RX = parse;                                                 // put the array into a string
  int firstcomma = Text_RX.indexOf(',');                                  // look for the first comma
  int secondcomma = Text_RX.indexOf(',', firstcomma + 1 );                // look for the second comma
  int thirdcomma = Text_RX.indexOf(',', secondcomma + 1 );                // look for the third comma
  int forthcomma = Text_RX.indexOf(',', thirdcomma + 1 );                 // look for the fourth comma
  int from = firstcomma + 2; int to = secondcomma - 1;                    // from and to hold where the phone no. is
  int Bypass = Text_RX.indexOf(10);                                       // Look for the first 'LINEFEED'
  int DataStreamStart = Text_RX.indexOf(10,Bypass + 1);                   // Get the 'text' index start
  int DataStreamFinish = Text_RX.indexOf(10, DataStreamStart + 1);        // Get the 'text' index finish
  String CalledByNumber = Text_RX.substring(from,to);                     // Strip out the phone No.
  String Data = Text_RX.substring(DataStreamStart+1,DataStreamFinish);    // Strip out the text
  CalledByNumber.toCharArray(Parse_from, 15);                             // put phone number in our array 'Parse_from'
  Data.toCharArray(Parse_Text,128);                                       // put phones text in our array 'Parse_Text'
}                                                                         // Phew!!!
You copied the character array into a String object so that you can re-implement the strtok function. Fine by me, but it adds a lot of unnecessary overhead. After re-implementing strtok, you then have to extract all the useful data from the String objects. All this copying is unnecessary if you simply passed this function the char array and used strtok.

Code:
    String stringOne = num2Dial;                                          // Check if its the allowed phone
    String stringTwo = Parse_from;
    if (stringOne == stringTwo)                                           // if the numbers match
    {
Now, you copy the extracted char arrays back to String objects, to avoid using strcmp. Is there a reason for this?

Code:
      delay(2000);                                                        // for 5 seconds
It's great when the comments match the code...

Code:
  String stringOne = test;
  String stringTwo = rx;
  if (stringOne == stringTwo) { return(true); } else { return(false); }
Or
Code:
return strcmp(test, rx) == 0;

Finally:
Code:
  char* alpha = err;                                                      // Get the command we errored on
Why don't you just print err?
33960  Using Arduino / Interfacing w/ Software on the Computer / Re: Where would you search or talk about new arduino products beside here? on: June 23, 2011, 05:33:37 pm
What does this have to do with interfacing with software?
Pages: 1 ... 2262 2263 [2264] 2265 2266 ... 3067