Show Posts
Pages: 1 [2] 3 4 ... 54
16  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.
17  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.
18  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:


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.
19  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.
20  Using Arduino / Programming Questions / Re: issues parsing data on: August 22, 2014, 07:54:10 am
What about something like the following:


char incomingMessage[30];
int messageLength;

void setup() {

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

By getting rid of the String object, the compiled code size drops from 3862 bytes to 2164. 
21  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:

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

  strcat(message, "bar");

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.
22  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.
23  Using Arduino / Programming Questions / Re: (byte*)(void*)&value ??? on: August 21, 2014, 11:54:26 am
Opps...didn't see that...
24  Using Arduino / Programming Questions / Re: (byte*)(void*)&value ??? on: August 21, 2014, 10:52:13 am
@AWOL: I don't understand your last post.
25  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:
26  Using Arduino / Programming Questions / Re: Help with Serial Hex Data on: August 20, 2014, 02:08:59 pm
There are still  a number of errors in your program. I was not able to get it to compile because I don't have your include file. Still, even if I did, I think there would still be a number of issues. To get you a little more comfortable with the Serial object, try the following simple program:

void setup() {

int counter = 0;
byte data[15];
void loop() {

  if (Serial.available()) {
    data[counter] =;


First, don't type anything but click the Send button on the monitor. The last number you see is a 10, which is the Linefeed character ('\n'). (There may be some garbage before it.)  Now type in "123" on the Serial input, click Send, and what do you see? You should see 49, 50, 51. If you look at an ASCII character table, you will see those are the ASCII codes for a '1', '2', and '3'. But also note that you still get a 10 at the end. So, if you want to read data up to when the user clicks the Send button, try:

   Serial.readBytesUntil('\n', data, 15);

where the 15 is the max number of bytes you want to read. You should try to work this into your program until you understand what each line is doing. I think that will help you see where your errors are.

27  Using Arduino / Project Guidance / Re: arduino uno with lcd display programming help !! on: August 20, 2014, 11:30:38 am
I would suggest that you contact your local high school physics teacher, college, community college, or vocational school and see if someone there can help you with a faster solution. Also, if there is an amateur radio (ham) radio club near you, they often have members who are familiar with the Arduino family of boards. You should be able to find someone locally who can help you more quickly.
28  Using Arduino / Programming Questions / Re: rtc clock on: August 20, 2014, 08:48:25 am
Most 1307 modules have an onboard battery that kicks in when you disconnect the USB cable. If you look at the sample code files for the library, you'll see that there are two separate programs: one to set the time and one to read the time. Your "read time" program should NOT contain any code that uses the Serial object, as that seems to reset the 1307. Calling Serial.begin() seems to cause the RTC to cache the current date/time and turn off the chip's internal counter. When power is reapplied, it restarts but uses the cached data. So, if there's a half hour between resets, the clock appears to be a half hour slow. I got around this by having one program initialize the clock and the "real" program use those values, but not use the Serial object.

You may have to make sure that calls to Serial.begin() begin before anything messes around with the RTC. I had to remove all calls to the Serial object to avoid caching the time. Given your goals of resetting on the fly, I'm not sure exactly how you want to do that. I'm just pointing out a problem I had. I am not familiar with the library you are using, but it seems strange to me that it creates its own instance of the RTC object behind your back.
29  Using Arduino / Programming Questions / Re: programming confusion on: August 18, 2014, 09:58:38 pm
If you define a variable without giving it a value, is it not automatically initialised to zero?

C++ is not required to initialize local variables. Some compilers do; other don't. Best practice: Assume local variables are initialized with garbage.
30  Using Arduino / Programming Questions / Re: programming confusion on: August 18, 2014, 09:19:01 pm
It has nothing to do with the comma operator.

Really? Try the statement leaving the comma operator out of the statement.  The comma operator does exactly what I said it does: It can be used to separate complex expressions.
Pages: 1 [2] 3 4 ... 54