Show Posts
Pages: 1 ... 117 118 [119] 120 121 ... 230
1771  Using Arduino / Programming Questions / Re: array average on: April 22, 2013, 04:47:07 pm
Hard to say with bullet point style code
1772  Using Arduino / Programming Questions / Re: How To Process a String of Several USART Commands on: April 22, 2013, 09:15:48 am
Did you really just post a screenshot of your code instead of posting your actual code that can be copied and manipulated?
1773  Using Arduino / Programming Questions / Re: Removing elements from array on: April 22, 2013, 09:07:44 am
I know that now, that's why I'm asking if there is a way to remove the element smiley
Like other languages have something like delete or remove functions, I just wanna know if there is something like that for Arduino smiley

No, there is no way to remove an element from a statically sized array. You can only set the value to something you have defined as empty and account for that when you are looking in the array.
1774  Using Arduino / Programming Questions / Re: Removing elements from array on: April 22, 2013, 09:03:58 am
No not like that..

The array is storing the floors where a person have clicked the button to call the elevator or a person in the elevator have clicked the button to that floor. Then when the elevator comes to the floor it will remove it from the array and continue to the next floor smiley

The problem you're having it that you're assuming assigning a value of '\0' or 0 to an element in the array "removes it" from the array. That's not what the array thinks. The array thinks you're just updating its value. If a value of 0 in an array slot means that the slot is "empty", then you need to have code that accounts for that, and not rely on the array to assume that's what you mean.
1775  Using Arduino / Project Guidance / Re: Changing my code from reading one analog input to multiple on: April 20, 2013, 10:40:46 am
Haha It was from trying to test different variations of the code, I just never deleted it.  smiley-red

If you want someone to review and critique your essay, you're not going to give them a paper full of chicken scratch.
1776  Using Arduino / Project Guidance / Re: Changing my code from reading one analog input to multiple on: April 20, 2013, 10:29:08 am
Why






is there so









much







white space in


your












code?
1777  Using Arduino / Programming Questions / Re: On/Off pin at set time help? on: April 20, 2013, 10:26:04 am
What have you tried?
1778  Using Arduino / Programming Questions / Re: Programming in Arduino Uno on: April 19, 2013, 11:17:56 pm
Code:
 if ( x = y){

= is assignment.
== is equality.
1779  Using Arduino / Programming Questions / Re: EEPROM read and write on: April 19, 2013, 02:22:21 pm
if you can offer constructive advice then please do.

Certainly.

PaulS has helped more people than probably most of us combined. So my constructive advice would be to grow thicker skin and take his advice/answer his questions.
1780  Using Arduino / Project Guidance / Re: Can you run 2 different loops in 1 sketch?? on: April 18, 2013, 07:50:26 pm

Too crazy?

You threw money at the problem; happens everyday.
1781  Using Arduino / Programming Questions / Re: Serial.read() to string? on: April 18, 2013, 05:30:20 pm
Because if I don't test its value when the word I send finishes, it continues to add blank spaces to the string.

What does that have to do with testing the value of a char before reading it? I'm not saying don't test the value, I'm saying read the value before you test it.

You really should restructure your code. The whole deal you are doing with the words variable is predicated on all of the information arriving within a single iteration of the loop, and is a workaround to avoid writing non blocking code. Look at the psuedo code I posted earlier; no need for a delay(), and less coding.
1782  Using Arduino / Programming Questions / Re: Serial.read() to string? on: April 18, 2013, 04:10:03 pm
So the question then becomes, why are you testing the value of inChar before reading it?
1783  Using Arduino / Programming Questions / Re: Problems with loading and reading an array on: April 17, 2013, 07:43:53 pm
Ok, so that makes sense... I'll have to look up/figure out how to parse that sizeof().

Simple macro for determining the number of elements in an array:

Code:
#define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])
1784  Using Arduino / Programming Questions / Re: Serial.read() to string? on: April 17, 2013, 04:20:17 pm
All those functions can be done by hand  if you want.

Not too difficult either (untested):

Code:
int char_indexOf(char *toSearch, char *toFind)
{
  int index = 0;
  while (toSearch[index] != '\0')
  {
    if (strncmp(toSearch+index, toFind, strlen(toFind)) == 0)
      return index;
    index++;
  }
  return -1;
}
1785  Using Arduino / Programming Questions / Re: Serial.read() to string? on: April 17, 2013, 03:46:21 pm
You're reading the data into a string (a null terminated array of chars). Why are you then creating a String (a memory fragmenting object) out of what you read? Why not just print the char array?

Pseudo code:

Code:
if there is a character to read
  read it
  if the character is a newline
    do something with the string
    clear the buffer
    reset the index
  else
    put the character into the buffer
    increment the index
    null terminate the buffer
  end if
end if
Pages: 1 ... 117 118 [119] 120 121 ... 230