Show Posts
Pages: [1] 2 3 ... 52
1  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.
2  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.
3  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. 
4  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.
5  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.
6  Using Arduino / Programming Questions / Re: (byte*)(void*)&value ??? on: August 21, 2014, 11:54:26 am
Opps...didn't see that...
7  Using Arduino / Programming Questions / Re: (byte*)(void*)&value ??? on: August 21, 2014, 10:52:13 am
@AWOL: I don't understand your last post.
8  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
9  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:

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

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

  if (Serial.available()) {
    data[counter] = Serial.read();
    Serial.println(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.

10  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.
11  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.
12  Using Arduino / Programming Questions / Re: programming confusion on: August 18, 2014, 09:58:38 pm
Quote
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.
13  Using Arduino / Programming Questions / Re: programming confusion on: August 18, 2014, 09:19:01 pm
Quote
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.
14  Using Arduino / Programming Questions / Re: programming confusion on: August 18, 2014, 07:10:50 pm
Yes. The comma operator can be used to separate complex expressions. For example, you could also do silly stuff like:

Code:
  for (int i, j = 9; j < 10; j++)


That said, most use the single line definitions rather than stacking them.
15  Using Arduino / Programming Questions / Re: My error correction doesn't seem to work? on: August 17, 2014, 01:15:10 pm
First, it would make your code more readable if you used Ctrl-T before you posted it.

Second, you set val in setup(), but never read or update it again. val2 is updated in loop() and compared to val3, but val3 is always based upon the value read in setup(). It would seem to me that if you are counting something, what that count is when the program starts doesn't matter much later on.

Third, your Serial.print() calls are placed in such a way they don't seem to do much good. Since val never changes in loop(), why print it out? Also, since val3 is just val + 100, it never varies either, which means val3 is a constant. If so, why not just set it as a const and be done with it?

Fourth, this code fragment:

Code:
  if (val2 > val3 )
  {
    delay(200);                     //wait icase of false positive reading
    if (val2 > val3)               //check sensor again
    {

is never going to change state. The delay() call has no way to change either val2 (since analogRead() isn't called but is the only thing that can change val2) or val3 (which is a constant).

Am I missing something?

Pages: [1] 2 3 ... 52