Show Posts
Pages: 1 ... 4 5 [6] 7 8 ... 58
76  Using Arduino / Programming Questions / Re: Cannot convert serial input from int to ASCII using atoi function on: August 26, 2014, 09:04:45 pm
Well, several things:

1) part of the problem is that 2147483648 is a tad bit bigger than will fit in an int
2) incomingByte is a horrible name for an int
3) itoa() converts from integer to ASCII but you're reading it as ASCII using the Serial object, so why convert it to what it already is?

I'm not sure I understand what you're trying to do.
77  Using Arduino / Programming Questions / Re: Can integer values be assigned to I/O prts? on: August 26, 2014, 09:29:50 am
This might be of interest:

http://arduino.cc/en/Tutorial/Fade
78  Using Arduino / Programming Questions / Re: Serial.available() returns wrong value. on: August 26, 2014, 08:45:51 am
Sometimes you can use the Serial object's readBytesUntil() method to simplify reading an input stream of text that has a known termination character (e.g., the newline, '\n').  A typical use can be shown with the following example:

Code:
#define MAXCHARS 50

void setup() {
 
 Serial.begin(115200);
 
}

void loop() {
 char message[MAXCHARS];
 int charCount;
 
 if (Serial.available() > 0) {
   charCount = Serial.readBytesUntil('\n', message, MAXCHARS - 1);
   message[charCount] = '\0';    // Make it a string
   Serial.print("characters read = ");
   Serial.print(charCount);
   Serial.print("   message = ");
   Serial.println(message);
  }
}
79  Using Arduino / Programming Questions / Re: Hi, where does the compiler look for libraries and which one does he take on: August 26, 2014, 08:31:50 am
You might find this helpful:

http://arduino.cc/en/Hacking/BuildProcess

80  Using Arduino / Programming Questions / Re: Running out of ram, help please. on: August 24, 2014, 11:57:43 am
Which Arduino board are you using and which version of the IDE? Also, what's the purpose of this line?

Code:
   while (index < ENTRY_SIZE);

If the code gets here, it seems like you'll spend a lot of time here since the loop body doesn't change anything.
81  Using Arduino / Programming Questions / Re: Passed data to method is null on: August 23, 2014, 11:22:24 pm
You don't have that many different elements in the notes[] array, so I would code those as bytes.  The frequency() function would have to be modified to interpret the byte values that come in to the proper frequencies, but I don't think that would be too hard. Next, I would change the beats[] array into byte values. Since you have a minimum value of .25 and a max value of 1.5, you could have a byte value of 1 correspond to .25, 2 = .50, 3 = .75, and so on.  This reduces the memory by 3 bytes per note. You can adjust the math for tempo * beats for the new values. The same indexing scheme can be applied to the notelist[] array. I think you'd have enough memory after doing that.
82  Using Arduino / Programming Questions / Re: Passed data to method is null on: August 23, 2014, 11:06:34 pm
That's a lot of arrays. What board are you using? My guess is that you're running out of memory.
83  Using Arduino / Programming Questions / Re: ERROR- 'mainColors () ; was not declared in scope. on: August 22, 2014, 10:07:13 pm
Your first post...welcome. You're missing the opening brace on the function:

Code:

void mainColors () {      // Note the opening brace at the end of the line


BTW, please read the first two posts on this Forum, which lay down the guidelines for posts to the Forum. The guidelines will help you get responses from the readers. First, please post your code using code tags. Second, try to reformat your code before posting using Ctrl-T in the IDE source window. These and other things should help you down the road.
84  Using Arduino / Programming Questions / Re: saving changes to sketches on: August 22, 2014, 12:46:10 pm
From within the IDE and with the code you want to save in the source code window:

1. Press Ctrl-A to highlight the code.
2. Press Ctrl-C to copy the source code to the copy buffer.
3. Press Ctrl-N to create a new source code window
4. Press Ctrl-A to highlight the framework code in the code window
5. Press Delete to remove the framework code.
6. Press Ctrl-C to copy the code from the copy buffer to the source code window
7. Press Ctrl-S to save the code using the file name of your choice.
85  Using Arduino / Programming Questions / Re: issues parsing Serial.read() data on: August 22, 2014, 07:54:10 am
What about something like the following:

Code:

char incomingMessage[30];
int messageLength;

void setup() {
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0) {
    messageLength = Serial.readBytesUntil('\n', incomingMessage, 29);
  }
  Serial.println(incomingMessage);
}

By getting rid of the String object, the compiled code size drops from 3862 bytes to 2164. 
86  Using Arduino / Programming Questions / Re: can't concat strings on: August 22, 2014, 07:43:19 am
Using the String class on any of the Arduino family is often not a good idea...too much memory. Try character arrays instead:

Code:
void setup() {
   char message[20] = "foo";

  Serial.begin(9600);
  strcat(message, "bar");
  Serial.println(message);
}

void loop() {

}

There is a huge number of functions available to you for using character array; strcat() is only one of them. BTW, the String version of the same program is 3482 while the code above only generates 2012 bytes.
87  Using Arduino / Programming Questions / Re: Blink LED program puzzle. on: August 21, 2014, 08:59:45 pm
After 29 posts to this Forum, we expect you to have read and start following the rules for posting as detailed in the first two stickies at the start of this Forum. Reading those and following what's contained therein will help you get responses from the rest of us.
88  Using Arduino / Programming Questions / Re: (byte*)(void*)&value ??? on: August 21, 2014, 11:54:26 am
Opps...didn't see that...
89  Using Arduino / Programming Questions / Re: (byte*)(void*)&value ??? on: August 21, 2014, 10:52:13 am
@AWOL: I don't understand your last post.
90  Using Arduino / Programming Questions / Re: (byte*)(void*)&value ??? on: August 21, 2014, 08:25:39 am
Following on AWOL's comments, if you want some help with Purdum's RIght-Left Rule and how it can be used to parse complex data definitions, see:

http://jdurrett.ba.ttu.edu/3345/handouts/RL-rule.html
Pages: 1 ... 4 5 [6] 7 8 ... 58