Show Posts
Pages: 1 ... 1171 1172 [1173] 1174 1175 ... 1744
17581  Using Arduino / Programming Questions / Re: Printing bytes and strings over serial on: August 23, 2011, 06:17:03 am
Another place where "for" loops save memory and make your program shorter.
I can't recommend them highly enough.
Or more frequently.
17582  Using Arduino / Programming Questions / Re: why no curly brackets in blink without delay ? on: August 23, 2011, 06:15:09 am
Quote
Faster. An add and a subtract will be slower than a single XOR.
The add is done by the compiler  ;-)
17583  Using Arduino / Programming Questions / Re: why no curly brackets in blink without delay ? on: August 23, 2011, 05:53:59 am
Quote
Oh wait, I should have said:

Code:

{
var ^= 2;
No you should have said:
Code:
var ^= 6;

or
Code:
var = 8 - var;
17584  Using Arduino / Programming Questions / Re: why no curly brackets in blink without delay ? on: August 23, 2011, 05:46:55 am
The lookup table is interesting and feasible, if a little wasteful of RAM.
It will certainly be quicker than a method involving a division operation on a processor that doesn't have a divide instruction.

The XOR is going to be as quick as the subtract method, but only if the operands are correct  ;-)
17585  Using Arduino / Programming Questions / Re: why no curly brackets in blink without delay ? on: August 23, 2011, 05:40:04 am
Quote
var ^= 2;
Well, thank you very much Mr Gammon, if you'd like to collect your expenses on your way out...
Next candidate, please.

See? Great question for sorting the wheat from the chaff.

Almost as good as the interviewee asked "What sort of range of numbers could you expect to store in an eight bit memory location?"
"Plus or minus 144" came back the answer.

Next.
17586  Using Arduino / Project Guidance / Re: Which compass module is easier to use? on: August 23, 2011, 05:29:38 am
Quote
does it eliminate the need of an external compass?
No, A GPS can only give heading if it is moving.
17587  Using Arduino / Programming Questions / Re: why no curly brackets in blink without delay ? on: August 23, 2011, 04:55:32 am
Take away from the sum of the number you first thought of!
17588  Using Arduino / Programming Questions / Re: why no curly brackets in blink without delay ? on: August 23, 2011, 04:46:42 am
That might work, but a divide is expensive.
17589  Using Arduino / Project Guidance / Re: programming language to interact with arduino on: August 23, 2011, 04:38:20 am
Quote
Processing is great. ... Also because wiring is based off of it its pretty familiar to use.
Wiring is based on C/C++, Processing is based on Java.
Don't get too familiar.
17590  Using Arduino / LEDs and Multiplexing / Re: 3by3 led cube control by matrix not working on: August 23, 2011, 04:21:41 am
Quote
111000000,
011100000,
001110000,
Why are some constants in decimal, and others in octal?
17591  Using Arduino / Programming Questions / Re: why no curly brackets in blink without delay ? on: August 23, 2011, 04:19:37 am
[OT] One of my favourite "weeding-out" interview questions used to be
"I have a variable that can have the value three or five.
If the value is three, make it five, if it is five, make it three.
Your answer should not contain an "if".
17592  Using Arduino / Programming Questions / Re: invalid conversion from 'char*' to 'unsigned char*' on: August 23, 2011, 04:09:01 am
Code:
WriteData(ptr++);
Right there.

Did you mean
Code:
WriteData(*ptr++);
?

The compiler errors are sometimes a bit cryptic, but here, I think they're pretty spot-on.
17593  Using Arduino / Programming Questions / Re: invalid conversion from 'char*' to 'unsigned char*' on: August 23, 2011, 04:02:53 am
Code:
LCDB.DisplayStringnew(0,0,(unsigned char*)lcdbuffer);//This should print RPM:22%
17594  Using Arduino / Programming Questions / Re: why no curly brackets in blink without delay ? on: August 23, 2011, 03:59:13 am
Code:
// if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

aka
Code:
ledState = !ledState;
17595  Using Arduino / Programming Questions / Re: invalid conversion from 'char*' to 'unsigned char*' on: August 23, 2011, 03:57:40 am
Code:
LCDB.DisplayStringnew(0,0,(uchar*)lcdbuffer);;//This should print RPM:22%
Pages: 1 ... 1171 1172 [1173] 1174 1175 ... 1744