Show Posts
Pages: 1 ... 90 91 [92] 93 94 ... 295
1366  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.
1367  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
1368  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.
1369  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.
1370  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.
1371  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.
1372  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.
1373  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 ?
1374  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.
1375  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.
1376  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.
1377  Using Arduino / Programming Questions / Re: Arduino School Project on: February 24, 2014, 04:10:42 pm
Code:
if (code=="00010");
I have not examined your code in detail to find the source of the errors but I did notice this line and many others like it straight away.  You need to lose the semi-colon at the end of the line.  With it in place your program will not work as intended because the if tests will be ignored.
1378  Using Arduino / Programming Questions / Re: How to connect Java with arduino? on: February 24, 2014, 02:39:32 pm
Can you provide a link to a tutorial that have you tried ?

What Java code is running on the PC ?
What code is running on the Arduino ?
1379  Using Arduino / Programming Questions / Re: Need help with JArduno on: February 24, 2014, 12:32:31 pm
Java code on an Arduino ?

What exactly are you running and where ?
1380  Using Arduino / Programming Questions / Re: Best practice for evaluating conditions on: February 24, 2014, 12:31:08 pm
Quote
For example, if I have 6 pushbuttons and they all need to be pushed for an LED to turn on.
You can test them all with a single if test.  No nesting.
Pages: 1 ... 90 91 [92] 93 94 ... 295