Show Posts
Pages: 1 ... 78 79 [80] 81 82 ... 283
1186  Using Arduino / Programming Questions / Re: While loop exit condition on: February 27, 2014, 02:02:30 am
That code does not compile making it difficult/impossible to help.
1187  Using Arduino / Programming Questions / Re: Blink with out delay on: February 26, 2014, 03:53:06 pm
Code:
  if(millis() >= goTime) functionGo();
There is a fundamental problem right here.  goTime is set to millis() in setup() and is never changed.  Therefore at any time after goTime is set millis() will always be greater or equal to goTime.
1188  Using Arduino / Programming Questions / Re: digitalRead question! on: February 26, 2014, 01:50:34 pm
How is the button wired ?  From where, to where and are you using a resistor in the circuit ?
1189  Using Arduino / Programming Questions / Re: While loop exit condition on: February 26, 2014, 01:47:50 pm
After going to the trouble of downloading and extracting your code (why not just attach the files ?) what do I find ?
The code does not even compile !
What is this all about ?
Code:
          case 2:
            lcd.setCursor(0,0);
            set_latitude();
            timedBeep(shortBeep,1);
            goto longi;
Not only do you have a (Yuk) goto in the program, the label that it tries to jump to does not even exist.
1190  Using Arduino / Programming Questions / Re: While loop exit condition on: February 26, 2014, 08:59:39 am
Time to post the whole of your current code then.
1191  Using Arduino / Programming Questions / Re: While loop exit condition on: February 26, 2014, 08:29:40 am
Your code may work but to me this would be clearer
Code:
while(button != btnLEFT)
{
  button = read_LCD_buttons();

  //code to be executed while the left button is not pressed goes here
}
//code to be executed when left button is pressed goes here
1192  Using Arduino / Programming Questions / Re: how to use attachInterrupt with serial on: February 26, 2014, 08:21:24 am
Quote
saw in the documentation which says when we use the attachInterrupt() the serial data gets lost.
Where did you see this ?
It is true that whilst an Interrupt Service Routine (ISR) is running interrupts are disabled so the Serial functions do not work as expected because they depend on interrupts, but merely attaching an interrupt does not interfere with Serial.
1193  Using Arduino / Programming Questions / Re: While loop exit condition on: February 26, 2014, 08:17:48 am
Code:
        while((button = read_LCD_buttons()) != btnLEFT)
Did you mean to put 2 statements in the while condition like that ?  What condition(s) are you testing for exactly ?
In my opinion it is much clearer to read the button state in one statement and then test its value in a second statement.
1194  Using Arduino / Programming Questions / Re: While loop exit condition on: February 26, 2014, 04:01:33 am
The while loop has only one condition
Code:
while(button!=btnSELECT)
It will exit when
Code:
button == btnSELECT
but in order for it to exit you must update either button or btnSELECT must be updated within the while or by an interrupt.
1195  Using Arduino / Programming Questions / Re: Stuck in a simple function programming on: February 26, 2014, 02:45:23 am
The problem is almost certainly caused by the fact that the function is defined within another one. 

Putting each brace on its own line and using Auto Format in the IDE will either show up the problem because the indenting will be wrong or Auto Format will not work because of too many left curly braces (at a guess).

Post all of the code here if you cannot sort out the problem yourself.
1196  Using Arduino / Programming Questions / Re: Remove +INQ the beginning of the inquiry on: February 26, 2014, 02:40:41 am
If you have a string like +INQ:1D:FE:720479,7A020C,7FFF you can separate the parts using the strtok() function which will allow you to split it apart.  http://www.cplusplus.com/reference/cstring/strtok/

Alternatively, if the string is of fixed length and format then you can use the positions of the characters within the char array in which the string is held to extract the parts you need.
1197  Using Arduino / Programming Questions / Re: Using the On-board push button as a on/off switch on: February 26, 2014, 01:59:23 am
Quote
since you can program the LED to use the push button
Where did you see this ?
1198  Using Arduino / Programming Questions / Re: Arduino melody note values on: February 25, 2014, 03:57:51 am
It would help considerably if you read and followed the advice in the stickies of this forum on how to post code.  As it is, half or more of your code is in italics because of an array index using i triggering italics mode.  Using code tags prevents the code being mangled and also presents it in a scrolling window in a fixed font.
1199  Using Arduino / Programming Questions / Re: compilation problem with the switch on: February 25, 2014, 02:28:07 am
flag2 is defined as an int.  When a match is found in the for loop you assign the int loop variable c to flag2.  So far so good, but when you use flag2 in the switch you try to match it with a char
Code:
      switch(flag2){
      case '1':
        c = "A";
        break;
      case '2':
        c = 'B';
        break;
The code section above has another problem because for some cases you try to assign a pointer to a constant char ("A") to a byte.  Put that mistake right and change the cases to ints rather than chars.
1200  Using Arduino / Programming Questions / Re: compilation problem with the switch on: February 24, 2014, 05:15:14 pm
The value used in a case statement can only  be an integer or something that can be represented by an integer.  Values like .- and --- cannot be represented by an integer, hence the error.
Pages: 1 ... 78 79 [80] 81 82 ... 283